FANDOM


Range Edit

A Range represents an interval—a set of values with a beginning and an end.

Example Ranges Edit

 ('a'..'e').to_a    #=> ["a", "b", "c", "d", "e"]
 (1..5).to_a        #=> [1, 2, 3, 4, 5]
 (-5..-1).to_a      #=> [-5, -4, -3, -2, -1]
 (-1..-5).to_a      #=> []

Another thing to note is that you can use ... to use a range from the start but not including the end ie.

 ('a'...'d').to_a   #=> ["a", "b", "c"]


External Link Edit

Ruby Docs: Range

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.