Search code examples
rubyenumerator

In ruby, what kind of object is (x..y)? An enumerator?


Ive seen this form crop up, for example, as:

 (x..y).map { |i| 2*i }.inject(:+)

so it seems to be creating an enumerator? But i can't find a definition of the syntax in ruby-docs and it's a hard string to google!

Thanks for any help!


Solution

  • Thse are Ranges which are described here: http://www.tutorialspoint.com/ruby/ruby_ranges.htm

    Or in the official docs they can be found here: http://www.ruby-doc.org/core-2.1.5/Range.html