Control flow

Control flow, also known as flow of control, refers to the order in which statements, instructions, or functions are executed within an application. Swift supports most of the familiar control flow statements that are in C-like languages. These include loops (including while), conditional statements (including if and switch), and the transfer of the control statements (including break and continue). It is worthwhile to note that Swift 3 does not include the traditional C for loop, and rather than the traditional do-while loop, Swift has the repeat-while loop.

In addition to the standard C control flow statements, Swift has also included statements such as the for-in loop and enhanced some of the existing statements, such as the switch ...

Get Mastering Swift 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.