swift if condition and code example
Example 1: if statement swfit
// if expression {
// do something
// }
var a: Int = 3
if a == 3 {
print("Hello World")
} else if a < 3 {
print("dlroW olleH")
} else {
print("42")
}
Example 2: swift 5 if statement
let a = -5
// if the condition is true then doThis() gets called else doThat() gets called
a >= 0 ? doThis(): doThat()
func doThis() {
println("Do This")
}
func doThat() {
println("Do That")
}