Hi --

On Sun, 8 Nov 2009, Roger Pack wrote:

> I'm considering suggesting that the base functionality for the
> enumerable-extra gem[1] be submitted into core.
>
> In a nut shell, it's that you can do
>
> list.map :name
>
> as an alternative to
>
> list.map &:name
>
> which is arguably less readable.
> Thoughts?

I'm very much in sympathy with the position that &:name is ugly. It's
always struck me as uncharacteristically line-noise-ish for Ruby
(though I also understand the motivation for it). I have trouble
talking myself into using it.

At the same time, the merit of &:name over :name is that &:name does
tell you what's going on, once you know that the & in front of any
object (symbol or otherwise) in last-argument position means that the
object will be converted to a Proc and play the block role.

Having :name magically understood as &:name is, for my taste, too much
invisible ink. It would also mean that map (and maybe other Enumerable
methods) had one argument syntax and all other iterators had another,
since presumably there's no general way to make method(:sym) know when
it's supposed to actually mean method(&:sym). I don't think that's a
useful special case.

(I know there's inject(:method), but note that that's a different
case; inject(:method) is not shorthand for inject(&:method).)


David

-- 
The          Ruby training with D. Black, G. Brown, J.McAnally
Compleat     Jan 22-23, 2010, Tampa, FL
Rubyist      http://www.thecompleatrubyist.com

David A. Black/Ruby Power and Light, LLC (http://www.rubypal.com)