Created
March 25, 2015 16:40
-
-
Save anonymous/3f511a93f4f1d5e79a7f to your computer and use it in GitHub Desktop.
duplicate module mix-in depending on order
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module M | |
end | |
class A | |
end | |
class B < A | |
end | |
b = B.new | |
class << b | |
include M | |
end | |
class B < A | |
include M | |
end | |
class << b | |
p ancestors | |
end | |
#[#<Class:#<B:0x007fb7ea8355c8>>, M, B, M, A, Object, Kernel, BasicObject] | |
#but if class B < A; include M; end before class << b; include M; end | |
#[#<Class:#<B:0x007ff6e2051438>>, B, M, A, Object, Kernel, BasicObject] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment