0
Q:

swift 5 if statement

// if expression {
// 	do something
// }

var a: Int = 3
if a == 3 {
	print("Hello World")
} else if a < 3 {
	print("dlroW olleH")
} else {
	print("42")
}
3
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")
}
0

New to Communities?

Join the community