swift Enumerations

swift Enumerations

enum、case、switch

CaseIterable allCases

要区别枚举变量和关联值

枚举变量参与枚举运算;

关联值和rawvalue不参与。

Associated Values

case qrCode(String)

case let .qrCode(productCode):

Raw Values

As an alternative to associated values, enumeration cases can come prepopulated with default values (called raw values), which are all of the same type.

同一类型的继承

enum ASCIIControlCharacter: Character