April 2017
Intermediate to advanced
316 pages
9h 33m
English
In Swift, an enumeration defines a common type for related values and enables us to work with those values in a type-safe way. Values provided for each enumeration member can be a String, Character, Int, or any floating-point type. Enumerations can store associated values of any given type, and the value types can be different for each member of the enumeration, if needed. Enumeration members can come pre-populated with default values (called raw values), which are all of the same type. Consider the following example:
enum MLSTeam { case montreal case toronto case newYork case columbus case losAngeles case seattle } let theTeam = MLSTeam.montreal
Enumeration values can be matched with a switch statement, which can be ...
Read now
Unlock full access