- 爲什麼我會覆蓋以下錯誤
talk: super: no superclass method talk (NoMethodError)
當我重寫已存在的方法? - 我該如何解決這個代碼來調用超級方法?
這裏是我使用在define_method中調用super時沒有超類方法
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")
見http://stackoverflow.com/questions/4470108/when-monkey-patching-a-method-can-you-call-the-overridden-method-from-the-new-i/4471202#4471202 –