Range
class Range
A Range
represents an interval—a set of values with a beginning and an end. Ranges may be constructed using the s..
e and s...
e literals, or with ::new. Ranges constructed using ..
run from the beginning 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