Answers for "simple if statement in swift"

1

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")
}
Posted by: Guest on April-08-2020
0

swift if statement

// check the number is positive or negative
let num = 15
var result = ""

if (num > 0) {
     result = "Positive Number"
}
else {
     result = "Negative Number"
}

print(result)
Posted by: Guest on May-08-2021

Code answers related to "Swift"

Browse Popular Code Answers by Language