I found this code in a RailsCast:
def tag_names
@tag_names || tags.map(&:name).join(\' \')
end
What does the (&:name)
Although we have great answers already, looking through a perspective of a beginner I'd like to add the additional information:
What does map(&:name) mean in Ruby?
This means, that you are passing another method as parameter to the map function. (In reality you're passing a symbol that gets converted into a proc. But this isn't that important in this particular case).
What is important is that you have a method
named name
that will be used by the map method as an argument instead of the traditional block
style.