16 lines
462 B
Plaintext
16 lines
462 B
Plaintext
// A match statement more like the traditional switch statement
|
|
// often seen in other languages.
|
|
enum PizzaTopping { Cheese, Pepperoni, Peppers, Pineapple }
|
|
|
|
let topping = Peppers
|
|
|
|
match (topping) {
|
|
Cheese => print("Would it really be pizza without it?"),
|
|
Pepperoni => print("An instant classic."),
|
|
Peppers => {
|
|
// We can use a block for more expressions.
|
|
print("For those who like to spice things up.")
|
|
},
|
|
Pineapple => print("You do you.")
|
|
}
|