Robert Dober wrote:
> I agree, *cool* and *somehow dangerous*, I would very conservatively 
> propose
> a proxy method, similiar in spirit to BDD's rspec#is
> 
> %w{the meaning of 42}.map.length => [3, too_long_to_count, 2, 2]
> 
> or maybe not overload #map without params for that purpose?

I like this idea too - something that allows you to pick which iterator 
method to use (that is: select, each, map)

Implementable syntax might be:

%w{the meaning of 42}.map_length

Where the Array.method_missing could parse it as:

          re = /(map|collect|select|each)_([\\w\\_]+)/
          if (match = method.to_s.match(re))
            puts match.inspect
            iterator, callmethod = match[1..2]
            puts [iterator, callmethod]
            return self.send(iterator) {|item| item.send callmethod}
          end

Cute. I've added it to the library.

-- 
Posted via http://www.ruby-forum.com/.