Loops
After the branching structures if and switch, the most common structures you'll use in your programming are looping structures, which cause your program flow to execute the same code iteratively.
The looping structures you'll learn in this section are the following:
for…in, which executes the same code a predetermined number of times
while and repeat…while, which executes code until a true condition becomes false
As with the switch control structure, there are many features and flexible options provided by these structures that make Swift more expressive and powerful than many other programming languages.
The for…in Statement
The following diagram illustrates how the for...in statement works:
Most programming languages have a for statement used to execute a code statement a certain number of times. The preceding diagram illustrates how the for...in statement works. A canonical example of a for loop in C, similar to many other C-inspired languages, is the following: ...