December 2015
Intermediate to advanced
400 pages
13h 3m
English
Swift also supports the classic for loop:
for initialization; condition; increment {
// Code to execute at each iteration
}
Semicolons separate the three parts of the for loop.
Each part performs a specific function in the three steps of the loop’s execution:
When the loop is entered, the initialization expression is evaluated to set up the iterator for the loop.
The condition expression is evaluated. If it is false, the loop is ended and execution of the code is transferred to after the loop. If it is true, then the code inside the loop’s braces ({}) is executed.
After the code between the braces is executed, the increment expression is executed. Depending on the code, the incrementer can be increased or ...
Read now
Unlock full access