Answers for "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
0

swift else if

if (condition1) {
    // code block 1
}

else if (condition2){
    // code block 2
}

else {
    // code block 3
}
Posted by: Guest on June-12-2021

Code answers related to "Swift"

Browse Popular Code Answers by Language