new===begineachendexclude_end?firstlastlengthsize A Range represents an interval---a set of values with a start
and an end. Ranges may be constructed using the
s..e and s...e literals, or
with Range.new. Ranges constructed using .. run from the
start to the end inclusively. Those created using ... exclude the
end value. When used as an iterator, ranges return each value in
the sequence.
(-1..-5).to_a
»
[]
(-5..-1).to_a
»
[-5, -4, -3, -2, -1]
('a'..'e').to_a
»
["a", "b", "c", "d", "e"]
('a'...'e').to_a
»
["a", "b", "c", "d"]
Ranges can be constructed using objects of any type, as long as the
objects can be compared using their <=> operator and they
support the succ method to return the next object in
sequence.
Constructs a range using the given start and end. If the
third parameter is omitted or is false, the range will
include the end object; otherwise, it will be excluded.