Conditional branching: if-statement
let a = 0
var b = 0
if a == 0 {
b = 1
}
// Parentheses can be used around the condition, but are not required.
if (a != 0) {
b = 2
}
// `b` is `1`let a = 0
var b = 0
if a == 1 {
b = 1
} else {
b = 2
}
// `b` is `2`Last updated