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 關注
- 713 瀏覽
添加回答
舉報
0/150
提交
取消
