12.4 An Overview of Enumerations
Enumerations (typically referred to as enums) are used to create custom data types consisting of pre-defined 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 example, none of the cases are assigned a value. An enum of this type is essentially used to reference one of a pre-defined set of states (in this case the current temperature being hot, warm or cold). Once declared, the enum may, for example, be used within a switch statement as follows:
func displayTempInfo(temp: Temperature) {
switch temp {
case .hot:
print("It is hot...