Last active
December 27, 2015 06:39
-
-
Save clicube/7282906 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 ModA | |
def methodA | |
puts "methodA of ModA called." | |
end | |
end | |
module ModB | |
include ModA | |
undef methodA | |
end | |
class ClassA | |
def methodA | |
puts "methodA of ClassA called." | |
end | |
end | |
a = ClassA.new | |
a.methodA # => methodA of ClassA called. | |
a.extend ModB | |
a.methodA # => NoMethodError |
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 ModA | |
def methodA | |
puts "methodA of ModA called." | |
end | |
end | |
module ModB | |
include ModA | |
undef methodA | |
end | |
class ClassA | |
include ModB | |
def methodA | |
puts "methodA of ClassA called." | |
end | |
end | |
class ClassB | |
def methodA | |
puts "methodA of ClassB called." | |
end | |
end | |
a = ClassA.new | |
a.methodA # => methodA of ClassA called. | |
b = ClassB.new | |
class << b | |
include ModB | |
end | |
b.methodA # => NoMethodError |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment