How would one convert the following to Swift from Objective-C?
if (myVar) return;
Swift does not use parentheses around the conditional, however the following code gives an error.
if myVar return
Well as the other guys also explained that braces are a must in swift. But for simplicity one can always do something like:
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")
}