Enum in swift

https://appventure.me/2015/10/17/advanced-practical-enum-examples/
http://brettbukowski.github.io/SwiftExamples/examples/enums/

Basics

When creating an enum for use, make sure you declare public. Whatever name labels
you declare do not implicitly map to values. Rather, they are their own values.
When a variable is assigned to an enum’s member, and gets printed, it will literally
print the the enum member.

Say we assign a variable to enum’s C.

..and you print out the enum:

output:
C Tats Maksen Bukaku!

It prints C because we assigned our var to Example.C

Assigning other types to your enum values

When you print it, you will literally get the enum value, and its type.

output:
Str(“hehe”)

Also, nil cannot be assigned (or initialized) to Example.

Raw Values

Raw values are compile-time set values directly assigned to every case within an enumeration, as in the example detailed below:

In the above example code, case “A” was explicitly assigned a raw value integer of 1, while cases “B” and “C” were implicitly assigned raw value integers of 2 and 3, respectively.

To Raw Values

given…

We can declare enum of certain type. This means that the enum values can contain Strings, Ints…etc.
Here, we have a enum that contains Strings. Even though we can simply use the enum values, those enum values also have raw values, which are the strings that we assign them to.

For example, here, have a whole bunch of enum values, they are enough and can be used. However, they also have String values attached to them.
In order to get the string values, you can use rawValue of the enum value.

From Raw Values

You can also declare the enum with the raw value, and try to get the enum value back.
The enum value returned is an Optional type.

skill contains the enum value name ‘GuileMove’, which is an Optional Type
skill has 2 properties: hashValue, and rawValue.

Associated Values

Associated values allow you to store values of other types alongside case values, as demonstrated below:

Other Examples

Enum conform to Protocol

implement function description.

Other examples

Multiple cases, one code block