Enumeration - Swift Programming
Enum Introduction Raw Values Associated Values CaseIterable Hashable Recursive Enumeration Introduction: An enumeration defines a common type for a group of related values and enables you to work with those values in a type-safe way within your code. Enumerations in Swift are much more flexible, and don’t have to provide a value for each case of the enumeration. Swift enumeration cases don’t have an integer value set by default, unlike languages like C and Objective-C. Enum cases don’t implicitly equal 0, 1, 2 and 3. Instead, the different enumeration cases are values in their own right, with an explicitly defined type of Enum Defined. Enumerations in Swift are first-class types. They adopt many features traditionally supported only by classes, such as 1. computed properties to provide additional information about the enumeration’s current value, and 2. instance methods to provide functionality related to the values the enumeration represents. Enumerations can also define ...