if condition {
//code
//code
} else if condition {
//code
//code
} else {
//code
//code
}
// short hand
condition ? true : false
Switch Case
switch varName {
case "is equal too?":
//code
case 100...200:
//code above is the range operator
case var1, var2, var3:
//code
default:
//code
}
Switch Case with WHERE
let x = 0
switch x {
case let y where y > 5:
// y binds to value of x
// where allows for a condition
print("x > 5")
case let y where y < 5:
print("x < 5")
default:
print("x = 5")
}
Comparison operators
== Equal to
!= Not Equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
&& AND
|| OR
! NOT
number...number // between and including number and number