- Hands-On Design Patterns with Swift
- Florent Vilmart Giordano Scalzo Sergio De Simone
- 62字
- 2021-07-02 14:44:58
Simple enums
Let's say you're building a smart light remote control; you can easily represent the state of this light with the following enum:
enum State {
case on
case off
}
let anOnLight = State.on
This is a very simple example, and we could have used a Boolean value, but with the enum, we set ourselves up for expansion.