O'Reilly logo

Learning iOS 8 Game Development Using Swift by Siddharth Shekar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Statements

Statements are of two kinds in any programming language—decision making statements and looping statements.

Decision-making statements

Decision making statements are of the following types: if, if else, else if, and switch. This is very standard in any programming language. Let's look at the if statement first and see how the syntax differs from other C-based languages.

The if statement

In Swift, the if statement is written like this:

if a > b {
    
    println("a is greater than b")
    
}

Immediately, the guys using C will be like, "Blasphemy!! No brackets!!" Yes, in Swift for the sake of simplicity and readability, you don't have to use the brackets. If you want to, you can still use them, and you won't get any compile errors.

But you absolutely must ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required