Range Operators
Learn how to declare ranges of values using the Swift range operators.
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
...