O'Reilly logo

Learn Swift 2 on the Mac, Second Edition by Waqar Malik

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter    7

Flow Control

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

Even though these constructs are familiar, they provide considerably powerful support for safety.

For Loops

A for loop construct provides a way for a block of code to be executed a 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required