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

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.

主站蜘蛛池模板: 依兰县| 宣汉县| 武宣县| 江达县| 双牌县| 文化| 湟中县| 隆安县| 昌图县| 乐东| 星子县| 镶黄旗| 荥经县| 天台县| 南川市| 海伦市| 井研县| 聂拉木县| 扬中市| 南宁市| 临夏县| 东平县| 加查县| 绵竹市| 铜梁县| 彭州市| 麻栗坡县| 银川市| 涿鹿县| 安化县| 宜阳县| 靖江市| 闵行区| 通化市| 宁城县| 武川县| 南溪县| 封丘县| 调兵山市| 拜泉县| 马关县|