Hi --

On Fri, 15 Dec 2006, Yukihiro Matsumoto wrote:

> Hi,
>
> In message "Re: map taking an argument (was: Re: join_with)"
>    on Thu, 14 Dec 2006 01:58:15 +0900, dblack / wobblini.net writes:
>
> |There was an RCR a while back, rejected by Matz, that asked for:
> |
> |   enum.map(:m)
> |
> |to be the same as:
> |
> |   enum.map {|e| e.m }
> |
> |It looks like Ruby >= 1.9 has this:
> |
> |   enum.map(&:m)
> |
> |which strikes me as the same thing, functionally, but visually noisier
> |and semantically more obscure.
> |
> |I'm just wondering what the rationale is for rejecting the simple
> |version and introducing the less simple one.
>
> (a) noisier form works not only for map, but also for every method
>    that take a block.
>
> (b) if we wanted to add same functionality for every iterator method,
>    we have to modify them all.  besides that, some iterator methods
>    already take arguments that make less noisy form difficult.
>
> (c) ampersand would serve as visual clue, which tells you that symbol
>    works as some kind of block.  it is difficult to tell what :m
>    means in less noisy form.  that could be a method name that map
>    based on instead of each, or some other thing.
>
> Choose whichever you want.

I'll take (a) and (b) :-)  I understand (c) too, though.


David

-- 
Q. What's a good holiday present for the serious Rails developer?
A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black)
    aka The Ruby book for Rails developers!
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
A. Ruby Power and Light, LLC (http://www.rubypal.com)