上QQ阅读APP看书,第一时间看更新
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.