O'Reilly logo

Swift Quick Syntax Reference by Matthew Campbell

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    17

Range Operators

You use range operators to specify a range of integers such as 1 through 10. There are two types of range operators: the closed range operator (...) and the half-open range operator (..<).

Closed Range Operator

The closed range operator gives you a way to specify a range of numbers when you want to include the number that defines the end of the range. You must specify the beginning of the range and the end of the range with the closed range operator (...), as shown in Listing 17-1.

Listing 17-1. Closed Range Operator

1...10

This operator is not useful by itself, but you will see range operators used in for loops (see Chapter 22), as shown in Listing 17-2.

Listing 17-2. Closed Range Operator in a for Loop

for i in ...

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