Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,18 @@
|
|||
let x = if (1 < 2) {
|
||||
":)"
|
||||
} else { // The else clause is required here as x is a string
|
||||
":("
|
||||
}
|
||||
|
||||
if (2 > 3) {
|
||||
print("This should never execute.")
|
||||
} // We can omit the else clause here
|
||||
|
||||
// We use else if for chaining
|
||||
if (1 > 2) {
|
||||
print("1 is less than 2")
|
||||
} else if (2 == 3) {
|
||||
print("2 is 3")
|
||||
} else {
|
||||
print("This should always execute.")
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
// 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.")
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
enum Topping { Cheese, Pepperoni, Peppers, Pineapple }
|
||||
enum Menu { Pizza(Topping), Calzone(Topping) }
|
||||
|
||||
let item = Calzone(Peppers)
|
||||
|
||||
match (item) {
|
||||
Calzone(topping) => {
|
||||
if (checkSpecials(topping)) {
|
||||
print("These are half off this week.")
|
||||
} else {
|
||||
print("No current specials.")
|
||||
}
|
||||
},
|
||||
_ => print("No current specials.")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue