Swift Enumerations

Learn how to use Swift enumerations to encapsulate a range of options within simple custom data types.

An overview of enumerations

Enumerations (typically referred to as enums) are used to create custom data types consisting of predefined sets of values. Enums are typically used for making decisions within code such as when using switch statements. An enum might, for example, be declared as follows:

enum Temperature {
    case hot
    case warm
    case cold
}

Note that in this ...