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

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.

主站蜘蛛池模板: 浠水县| 崇文区| 西畴县| 郁南县| 翁牛特旗| 平乡县| 枣阳市| 城步| 通辽市| 乐安县| 株洲县| 盐源县| 花莲市| 安平县| 徐州市| 花垣县| 凤阳县| 清流县| 即墨市| 阳信县| 怀宁县| 腾冲县| 哈密市| 格尔木市| 保定市| 辽阳县| 孟州市| 荆州市| 远安县| 开鲁县| 南投市| 监利县| 香河县| 榆社县| 昌江| 昭觉县| 武汉市| 手游| 定南县| 伊通| 鱼台县|