I’ve bought and read Simply Rails 2, taught me a bit but my problem now
is that Rails is so easy that often you can get all of the functionality
you need in an app without getting into any thought-provoking Ruby
programming. If I run into a wall I just hit up Google or you guys-
which isn’t really ‘teaching’ me.

Have you done any benchmark testing on using the &: method? I would be
curious as to why you say it’s slower.

As for uglier - I think that’s a personal preference. I personally would
never recommend chaining 3 methods together as you did for fear that one
would fail causing the infamous “undefined method … for nil”. To my
eyes, the map.(&:email) is very clean and easy to read without a bunch
of nasty |v| v.email, etc.

I would be curious about performance tests though since you say it’s
slower. I haven’t noticed any major performance hit, but I’ve never
really tested.

Have you done any benchmark testing on using the &: method? I would be
curious as to why you say it’s slower.

PMFJI… As I recall, the &:foo notation is a shortcut for
Symbol#to_proc so the following code snippets are the same:

def frazzle
self.name.split(//).sort_by{rand}.join(’’)
end

@stuff.each(&:frazzle)

@stuff.each{|s| Proc.new{|*args| args.shift.send(s, *args)}}

Look in active_support/symbol.rb

So what could make this slower are the facts that 1) you are creating
a new anonymous proc for each iteration through the @stuff collection;
and 2) you are using the send method to invoke the method referenced
by the symbol. Contrast that to:

@stuff.each{|s| s.frazzle}

In this case, the method is being invoked directly, skipping the steps
of creating the anonymous proc and then invoking “frazzle” via a send.

So, that’s how I understand it. Now, in the case where you have a
dozen users returned and want to list their names next to checkboxes,
the performance difference is negligible. It’s the case where you
can’t predict the size of the result set that you want to beware of.

Have you done any benchmark testing on using the &: method? I would be
curious as to why you say it’s slower.

PMFJI… As I recall, the &:foo notation is a shortcut for
Symbol#to_proc so the following code snippets are the same:

def frazzle
self.name.split(//).sort_by{rand}.join(’’)
end

@stuff.each(&:frazzle)

@stuff.each{|s| Proc.new{|*args| args.shift.send(s, *args)}}

Look in active_support/symbol.rb

So what could make this slower are the facts that 1) you are creating
a new anonymous proc for each iteration through the @stuff collection;
and 2) you are using the send method to invoke the method referenced
by the symbol. Contrast that to:

@stuff.each{|s| s.frazzle}

In this case, the method is being invoked directly, skipping the steps
of creating the anonymous proc and then invoking “frazzle” via a send.

So, that’s how I understand it. Now, in the case where you have a
dozen users returned and want to list their names next to checkboxes,
the performance difference is negligible. It’s the case where you
can’t predict the size of the result set that you want to beware of.