Our enum type ServerState has an underlying int type.
The possible values for ServerState are defined as constants. The values are automatically assigned starting from 0.
By implementing the CustomStringConvertible protocol, values of ServerState can be printed out or converted to strings.
If we have a value of type Int, we cannot pass it to transition - the compiler will complain about type mismatch. This provides some degree of compile-time type safety for enums.
To run the program, put the code in a Swift file and use swiftc to compile it.
Now we have a basic understanding of how to use enums in Swift, let’s explore more about the language.