Range Operators and Loops

In the last chapter, you looked at conditionals, which allow you to do different things based on different conditions, and optionals, which enable you to create variables that may or may not have a value. You were able to create more complex programs.

Sometimes, you will need to represent a range of numbers instead of discrete values. Swift uses range operators for this, which makes it easy to specify the start and end points for a range. You will learn about the different types of range operators in this chapter.

In programming, you frequently need to repeat an operation over and over again. Swift handles this by using loops. You can repeat a sequence a fixed number of times, or repeat a sequence until a condition ...

Get iOS 13 Programming for Beginners - Fourth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.