This seems a bit of an anomoly:

>> x = [1,2,3].map
>> x.each { |y| y*2 }
=> [1, 2, 3]            # I was expecting [2, 4, 6]

It seems that Array#map and Enumerable#map without a block return just
an Array. However most other Enumerable methods return an Enumerator,
even #each (which is pretty useless, since the Enumerator maps #each to
#each)

>> RUBY_DESCRIPTION
=> "ruby 1.8.7 (2009-06-12 patchlevel 174) [x86_64-linux]"

>> [1,2,3].each
=> #<Enumerable::Enumerator:0x7fa4170ea1b0>

>> [1,2,3].map
=> [1, 2, 3]
>> [1,2,3].collect
=> [1, 2, 3]

>> class Foo; include Enumerable; def each; yield 1; end; end
=> nil
>> Foo.new.map
=> [1]

Anybody got a good explanation for this?
-- 
Posted via http://www.ruby-forum.com/.