官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 巴彦淖尔市| 平潭县| 太谷县| 江西省| 馆陶县| 乌苏市| 米泉市| 黄大仙区| 宁南县| 龙游县| 腾冲县| 合山市| 罗源县| 泗水县| 日土县| 临汾市| 如皋市| 桐柏县| 龙江县| 孝义市| 甘泉县| 进贤县| 神池县| 岢岚县| 广昌县| 万山特区| 钦州市| 赤城县| 寻甸| 永顺县| 龙陵县| 军事| 鹰潭市| 云阳县| 衡水市| 信丰县| 三明市| 日照市| 安阳市| 通城县| 福清市|