- Hands-On Design Patterns with Swift
- Florent Vilmart Giordano Scalzo Sergio De Simone
- 113字
- 2021-07-02 14:44:58
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.
推薦閱讀
- Creating Mobile Apps with Sencha Touch 2
- 大數(shù)據可視化
- Access 2016數(shù)據庫技術及應用
- 算法與數(shù)據中臺:基于Google、Facebook與微博實踐
- Scratch 3.0 藝術進階
- 數(shù)據庫技術實用教程
- INSTANT Apple iBooks How-to
- 數(shù)據科學實戰(zhàn)指南
- Hadoop集群與安全
- Unreal Engine Virtual Reality Quick Start Guide
- 企業(yè)主數(shù)據管理實務
- 改進的群智能算法及其應用
- 量化投資:交易模型開發(fā)與數(shù)據挖掘
- 深入理解Flink:實時大數(shù)據處理實踐
- Unity 4.x Game AI Programming