I found this code in a RailsCast:
def tag_names @tag_names || tags.map(&:name).join(\' \') end
What does the (&:name)
(&:name)
Here :name is the symbol which point to the method name of tag object. When we pass &:name to map, it will treat name as a proc object. For short, tags.map(&:name) acts as:
:name
name
&:name
map
tags.map(&:name)
tags.map do |tag| tag.name end