Two Types of Ranges in Ruby
Today I learned there are two ways to construct a
range in ruby. Using two dots ..
creates a range including the start and end values.
Using three dots ...
creates a range including the start value, but not the
end value.
So if we think of them in terms of
intervals, (a..b)
is
a closed interval ([a, b]
), and (a...b)
is a right half-open interval ([a, b)
).