Created
July 24, 2014 14:44
-
-
Save xuncheng/93ccfe8a45ed24534235 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
class Parent | |
def say | |
puts "In Parent" | |
end | |
end | |
module A | |
def say | |
puts "In A" | |
super | |
end | |
end | |
module B | |
def say | |
puts "In B" | |
super | |
end | |
end | |
class Child < Parent | |
include A, B | |
end | |
# Child.ancestors | |
# => [Child, A, B, Parent, Object, Kernel, BasicObject] | |
p = Child.new | |
p.say | |
=> In A | |
In B | |
In Parent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment