我知道,我可以從模塊這樣我可以用模塊覆蓋實例方法嗎?
class Foo
class << self
def some_static_method
puts 'some_static_method'
end
end
end
module BAR
class << Foo
def some_static_method
puts 'another_static_method'
end
end
end
class Foo
include BAR
end
Foo.some_static_method # => 'another_static_method'
覆蓋類的方法是否有可能爲一個實例方法?
您可能會發現一些信息[這裏](http://stackoverflow.com/questions/5944278/overriding-method-by-another-defined-in-module)。 – maxdec