02. Inclue Enumeration

It will take about 1 minutes to finish reading this article.

We can also embed enumerations in structures or classes.

Example Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
struct MyCharacter {
enum CharacterType {
case thief
case warrior
case knight
}

enum Weapon {
case bow
case sword
case lance
case dagger
}

let type: CharacterType
let weapon: Weapon

}

Call as follows:

1
let warrior = MyCharacter(type: .warrior, weapon: .sword)