A quick review of enum concepts in Swift via code examples
case .begin
Enums are a type safe way to deal with related values
Syntax
Switch Statements
Raw Values
Raw Values: Implicitly Assigned Values
You need to specify the raw value type before accessing it
Default Values for Int
Notice what happens when you assign a value to one case
Initialization from Raw Value
👀 Note: Raw Value initializer is a failable initializer !
Associated Enums
Note how the associated value can be used or even omitted in different ways in a switch case:
Iterating
Implement ‘CaseIterable’ in the definition of the enum or even an extension of the enum
case .theEnd