Switch and Enums
suggest changeThe 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.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents