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: ,

No comments yet.

Leave a Reply