從不。紅寶石確實而不是支持MI(但看到性狀作爲一個有用的替代品)。
無論如何,這個類的重新定義是不明確的,並且會根據特定的Ruby實現產生不同的效果。當我運行給定的代碼時,我得到「TypeError:類的超類不匹配..」(Ruby 1.9.2; 1.9.3錯誤出現延遲)。
如果有問題的代碼不會導致這樣的錯誤,檢查MyTest.superclass
看什麼超真的說重新定義後:注意:#superclass
返回單類對象,而不是收藏。
這裏是反例認爲這種重新定義方案不不添加或指示MI:
class A
def a; "a"; end
end
class B
def b; "b"; end
end
class C < A
end
# This may raise said TypeError, but if it does not then ..
class C < B
end
# .. either this will work
C.new.a
# .. /or possibly/ this will work
C.new.b
# If the redefinition added MI then /both/ would work.
# If such an implementation is found, please let me know!
(我不能得到上述以募集不說的TypeError工作)。
+1這。 OP正在運行實施細節。 –