From: Gregory Brown Date: 2010-01-28T00:09:17+09:00 Subject: Re: Inconsistency - map/collect not returning enumerator On Wed, Jan 27, 2010 at 8:29 AM, Brian Candler wrote: > 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]" > Anybody got a good explanation for this? Yes. You're using Ruby 1.8.7, which is, in and of itself, an anomaly :) But this may be to preserve compatibility with Ruby 1.8.6: >> RUBY_VERSION => "1.8.6" # NOT OK TO CHANGE BEHAVIOR > [1,2,3].map => [1, 2, 3] # OK TO ADD BEHAVIOR >> [1,2,3].select LocalJumpError: no block given from (irb):3:in `select' from (irb):3