Jonathan Fantham wrote:
> On another side note:
> 
> @Ryan - You wrote:
> 
> A more efficient way is to do this is:
> @project_names = Project.all(:select => 'name').map(&:name)
> 
> While you've made a database optimisation there, you've also used the
> shorthand notation for the map function. I read somewhere that map
> (&:name) is quite a bit less efficient than map{ |p| p.name }
> 
> unfortunately I can't find the article that convinced me in the first
> place... I can only find this blog with the issue mentioned in the
> comments:
> 
> http://blog.hasmanythrough.com/2006/3/7/symbol-to-proc-shorthand

The Symbol#to_proc syntax is slower than a block, but unless you're 
doing it thousands of times, the single trip to the database is probably 
at least a few orders of magnitude more expensive.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to