On May 13, 2009, at 11:07 PM, Gregory Brown wrote:
> On Wed, May 13, 2009 at 11:03 PM, Daniel DeLorme <dan-ml / dan42.com>  
> wrote:
>> Yes, I know, and that was kind of my point. The to_proc conversion
>> became popular because people want a shortcut notation for this  
>> common
>> case, but IMHO map(&:foo) is way uglier than map{.foo}, and as a  
>> bonus you
>> could even do map{.foo.bar}  :-)
>
> I don't know.   I think they're about the same in terms of looks, and
> the former doesn't require changes to the parser.
>
> -greg


plus, doing your .foo.bar has to contend with .foo being nil (or  
otherwise having a NoMethodError for :bar)

some_collection.map{|e|e.foo.bar}

really isn't too bad anyway and if you want to handle the possible  
exception:

some_collection.map{|e|e.foo.bar rescue nil}

possibly with a .compact thrown on the end.

The parser already refused to treat .5 as a Float literal insisting  
that it be 0.5 so I doubt that .foo would get any more favorable  
treatment as a special case (since .5 isn't really all that special).

-Rob

Rob Biedenharn		http://agileconsultingllc.com
Rob / AgileConsultingLLC.com