map(&:name)在Ruby中意味着什么?我在铁路:def tag_names @tag_names || tags.map(&:name).join(' ')end是什么(&:name)在……里面map(&:name)刻薄?
4 回答
杨__羊羊
TA贡献1943条经验 获得超7个赞
#to_proc#to_proc
class Array
def to_proc
proc { |receiver| receiver.send *self }
endend# And then...[ 'Hello', 'Goodbye' ].map &[ :+, ' world!' ]#=> ["Hello world!", "Goodbye world!"]&to_proc#to_proc
[ 'Hello', 'Goodbye' ].map { |receiver| receiver.send( :+, ' world!' ) }- 4 回答
- 0 关注
- 719 浏览
添加回答
举报
0/150
提交
取消
