- 为什么我
talk: super: no superclass method talk (NoMethodError)
在覆盖已存在的方法时会收到以下错误? - 如何修复此代码以调用超级方法?
这是我正在使用的示例代码
class Foo
def talk(who, what, where)
p "#{who} is #{what} at #{where}"
end
end
Foo.new.talk("monster", "jumping", "home")
class Foo
define_method(:talk) do |*params|
super(*params)
end
end
Foo.new.talk("monster", "jumping", "home")