Created
June 18, 2018 08:31
-
-
Save stokarenko/3122ff650657ab6061a7c592a4cd42f7 to your computer and use it in GitHub Desktop.
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 A | |
def func | |
p 'A' | |
super | |
end | |
end | |
class B | |
def func | |
p 'B' | |
super | |
end | |
end | |
class C < B | |
def func | |
p 'C' | |
super | |
end | |
end | |
B.include A | |
p C.ancestors # [C, B, A, Object, Kernel, BasicObject] | |
C.new.func # "C", "B", "A", "no superclass method `func'" |
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 A | |
def func | |
p 'A' | |
super | |
end | |
end | |
module B | |
def func | |
p 'B' | |
super | |
end | |
end | |
class C | |
include B | |
def func | |
p 'C' | |
super | |
end | |
end | |
B.include A | |
p B.ancestors # [B, A] | |
# NOTE: A is missing! | |
p C.ancestors # [C, B, Object, Kernel, BasicObject] | |
C.new.func # "C", "B", "no superclass method `func'" |
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 A | |
def func | |
p 'A' | |
super | |
end | |
end | |
module B | |
include A | |
def func | |
p 'B' | |
super | |
end | |
end | |
class C | |
include B | |
def func | |
p 'C' | |
super | |
end | |
end | |
p B.ancestors # [B, A] | |
p C.ancestors # [C, B, A, Object, Kernel, BasicObject] | |
C.new.func # "C", "B", "A", "no superclass method `func'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment