April 2015
Intermediate to advanced
556 pages
17h 47m
English
Swift has all the familiar control flow statements:
if-else, which you saw above, while,
for, for-in, do-while, and switch.
While they are familiar, there may be some differences from what you
are accustomed to.
The key differences with C-like languages is that while enclosing
parentheses are not necessary on these statements’ expressions,
braces on clauses are necessary.
Additionally, the expressions for if and while-like statements
must evaluate to a Bool.
Consider this very traditional C-style loop, written in Swift:
for var i = 0; i < countingUp.count; i++ {
let string = countingUp[i]
// Use 'string'.
}
You could do the same thing a little more cleanly using
Swift’s Range type and the for ...
Read now
Unlock full access