Swift Enumerations / Swift Enum
Swift Enumeration is also known as Swift Enum. It is a data type which consists of set of related values. It is declared in a class and its values are accessed through the instance members of that class.
Let's take an example to understand it well. Here, we shall an enum named "Connection Status" and see the possible condition using switch statement.
In the above example, there are 4 cases: Unknown, Disconnected, Connecting, and Connected. The output is showing as "Connected" as it is set as connected. If you set it "Disconnected", it will show "Disconnected" as output.
This is how we use enumeration in Swift.
Next TopicSwift Structures