Type¶
Enumerations¶
A data type with a set of discrete values.¶
Overview¶
Enumerations are often user defined types with discrete values.
struct ExampleView: View {
var myFruit: Fruit = .Banana
var body: some View {
switch myFruit {
case .Apple:
Text("🍏🍏")
case .Peach:
Text("🍑🍑")
default:
Text("🍌🍌") // Displays 🍌🍌
}
}
}
enum Fruit{
case Banana
case Apple
case Peach
}