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

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.

主站蜘蛛池模板: 西充县| 光山县| 微博| 久治县| 南开区| 和平区| 墨玉县| 大邑县| 韶山市| 惠东县| 休宁县| 天津市| 鹤庆县| 周至县| 黔西县| 宁陵县| 江城| 江安县| 永仁县| 海门市| 永寿县| 铁岭市| 五峰| 信宜市| 大兴区| 葫芦岛市| 陆川县| 军事| 舟山市| 青州市| 和田市| 河曲县| 鞍山市| 花莲市| 临西县| 农安县| 娱乐| 改则县| 尼玛县| 临泽县| 伊宁市|