Swift Language Switch and Enums


Example

The Switch statement works very well with Enum values

enum CarModel {
    case Standard, Fast, VeryFast
}

let car = CarModel.Standard

switch car {
case .Standard: print("Standard")
case .Fast: print("Fast")
case .VeryFast: print("VeryFast")
}

Since we provided a case for each possible value of car, we omit the default case.