Chapter    7

Flow Control

In programming, Control Flow referes to the order of instructions (statements) are executed. Swift provides the standard set of conditional constructs. These include for, while, if and switch, plus break and continue to transfer the control to another location in the code.

Even those these are constrcts are familiar but they provide considerably powerful support for safety.

For Loops

A for loop construct provides a way for a block of code to be executed number of times. Swift provides two types of for loops.

  • For-in is used in conjunction with objects that are contained in a range, sequence, collection, or progression. These typically include arrays and dictionaries.
  • For-conditional-increment performs a block of code ...

Get Learn Swift on the Mac: For OS X and iOS 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.