to_proc or not to_proc

Instead of writing this

[sourcecode language='ruby']
Profile.find(:all).collect{ |x| x.email }
[/sourcecode]

I could write this using Rails’ Symbol#to_proc

[sourcecode language='ruby']
Profile.find(:all).collect(&:email)
[/sourcecode]

Nice.

Tags: ,

One Response to “to_proc or not to_proc”

  1. Jaime Razer 23. Oct, 2010 at 2:27 pm #

    Many thanks for taking this possiblity to talk about this, I feel strongly over it and I make use of researching this subject. When possible, because you gain data, please update this web site with new information. I have found it extremely useful.

Leave a Reply