【发布时间】:2018-10-13 19:42:40
【问题描述】:
receiver_method(&:method) 功能似乎很清楚,但我发现关于 assignment to 'obj' 的解释*有一个空白,例如——
class Symbol
def to_proc #<parameter notably absent>
Proc.new { |obj, *args|
obj.send (self, *args)
}
end
end
这如何将接收器方法的对象/传递的参数分配为“obj”?
* What does map(&:name) mean in Ruby?
* https://www.skorks.com/2013/04/ruby-ampersand-parameter-demystified/
【问题讨论】: