O'Reilly logo

Learning Swift™ Programming by Jacob Schatz

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

Control Flow: Making Choices

Controlling the order in which code executes is a crucial aspect of any programming language. By building on the traditions of C and C-like languages, Swift’s control flow constructs allow for powerful functionality while still maintaining a familiar syntax.

for Loops

At its most basic, a for loop allows you to execute code repeatedly. You can also say that code statements are “looping” a certain number of times (or infinitely). In the Swift language, there are two distinct types of for loops to consider. There is the traditional for-condition-increment loop, and there is the for-in loop. for-in is often associated with a process known as fast enumeration—a simplified syntax that makes it easier to run specific code ...

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