Range Operators
Explore Swift's range operators to declare value ranges efficiently. Understand the closed, half-open, and one-sided range operators, and how they apply to loops and collections. This lesson helps you write cleaner, more effective Swift code for mobile app development.
We'll cover the following...
We'll cover the following...
Swift includes several useful operators that allow you to declare ranges of values. As we will see in a later lesson, these operators are invaluable when working with looping in program logic. Swift currently supports closed range, half-open, and one-sided range operators.
Closed range operator
The syntax for the closed range operator is as follows:
x…y
This operator represents the range of numbers starting at x and ending at y where both x and y are included within the range. The range operator ...