Swift Range Operators
Swift: Range operators
Swift includes two range operators, two dots, three dots.
The closed range operator (a...b)
defines a range that runs from a
to b
, and includes the values a
and b
.
The half-closed range operator (a..b)
defines a range that runs from a
to b
, but does not include b
.
Nice! Just like in Ruby. Hold on, heck no. It's flipped around?
Ranges may be constructed using the s..e
and s...e
literals
Ranges constructed using ..
run from the beginning to the end inclusively.
Those created using ...
exclude the end value.