[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: map taking an argument (was: Re: join_with

Yukihiro Matsumoto

12/14/2006 3:33:00 PM

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.

matz.

1 Answer

dblack

12/14/2006 4:43:00 PM

0