> %w(action_controller/railtie action_mailer/railtie).map &method(:require)
=> [true, true]
并且方法调用返回一个Method的实例。
> method(:require)
=> #<Method: Object(Kernel)#require>
所以方法中必须有一个 to_proc 定义,它应该类似于
class Method
def to_proc
proc { |obj| self.send(obj) }
end
end
我的问题是 rails 在 Method 中是否覆盖了这个 to_proc 或者什么。
为什么以下命令的行为方式与其行为方式相同
> %w(action_controller/railtie action_mailer/railtie).map &method(:require)
=> [true, true]