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

Enums

Enums are one of the basic constructs that the Swift language offers. At the same level as classes, structs, and functions, they are used to represent values that can only have a finite amount of states.

Take the Optional enum, for example; it is represented by an enum perfectly. It represents a value that can have two, and only two, states, represented by the two members of the Optional enum. It can either be initialized to .none or filled with a value, .wrapped(value).

Enums are incredibly powerful in Swift. From very simple cases to generics, they are among the most powerful tools that we have for writing our programs.

主站蜘蛛池模板: 新密市| 中宁县| 哈尔滨市| 陈巴尔虎旗| 西藏| 祁门县| 禄丰县| 额尔古纳市| 德保县| 彭山县| 沾益县| 叶城县| 苗栗市| 石泉县| 雷波县| 丹寨县| 巴中市| 盐亭县| 辽宁省| 阿克| 临高县| 安龙县| 钟祥市| 长汀县| 安泽县| 宁陕县| 通州市| 锡林浩特市| 马关县| 乐平市| 余干县| 五台县| 越西县| 肥乡县| 蒙自县| 汾西县| 宁乡县| 乌兰察布市| 宜都市| 日土县| 耿马|