Enums with Power basics
Define enums with raw or associated values, use switch for exhaustive matching, and model states with them.
Intro
Swift enums go beyond simple constants. They can have raw values or associated values and work with exhaustive switch statements.
Raw values
Raw values assign a constant value to each case, e.g., String or Int.
enum Direction: String {
case north = "N"
case south = "S"
}
print(Direction.north.rawValue)All lessons in this course
- Enums with Power basics
- Powerful switch with pattern matching
- Finite state modeling