Could you explain what the code below is doing:
resp = s3.list_buckets
puts resp.buckets.map(&:name)
My question is specific to map
. I am not able to understand how map
is being used here. Also, what does (&:name)
mean?
I referred map documentation. However, I'm not able to correlate it with the map in the code above. Per the documentation, Map should be followed by a {}
, but it is followed by a ()
in the code above.
In perl context, map
will work on an array/list and will return a new array/list. So, it seems to be doing something similar here as well, but I cannot decode that.
Any pointers to documentation would be helpful.