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!
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!
irb(main):001:0> (1..3).class
=> Range
And while we are on documentation and stuff, let me suggest omniref
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