Trying to understand Ruby a bit better, I ran into this code surfing the Internet:
require \'rubygems\'
require \'activeresource\'
ActiveResource::Base.lo
events.map(&:name)
is exactly equivalent to
events.map{|x| x.name}
it is just convenient syntactic sugar.
For more details, check out the Symbol#to_proc
method here. Here, :name
is being coerced to a proc.
By the way, this comes up often here - it's just very hard to google or otherwise search for 'the colon thing with an ampersand' :).