Lesson 7 of 21 · Markup
Enums and match
An enum names each state that a value can have. #match shows one branch for each case, and the compiler rejects a match that forgets a case. So the compiler tells you about each new case.A case can hold data. An arm receives this data as a name.Your turn
- Add the case failed(reason: String) to Load.
- Add an arm for it. The compiler shows an error until you add this arm.
- Add a button that sets load = .failed("No network").
Preview
1 error
The sandbox needs a browser.