## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

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.

No credit card required