7. Swift Control Flow
Regardless of the programming language used, application development is largely an exercise in applying logic, and much of the art of programming involves writing code that makes decisions based on one or more criteria. Such decisions define which code gets executed, how many times it is executed and, conversely, which code gets by-passed when the program is executing. This is often referred to as control flow since it controls the flow of program execution. Flow control typically falls into the categories of looping control (how often code is executed) and conditional flow control (whether code is executed). This chapter is intended to provide an introductory overview of both types of flow control in Swift.
7.1 Looping Control Flow
This chapter will begin by looking at control flow in the form of loops. Loops are essentially sequences of Swift statements which are to be executed repeatedly until a specified condition is met. The first looping statement we will explore...