Created
October 16, 2016 06:59
-
-
Save kodaitakahashi/46f746888539c65d29551896b1186070 to your computer and use it in GitHub Desktop.
includeとprependを使ったメソッド探索
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 M1; end | |
module M2; end | |
class C | |
include M1 | |
prepend M2 | |
end | |
a = C.new | |
a.ancestors #=> [M2, C, M1, Object, PP::ObjectMixin, Kernel, BasicObject] |
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 M1 | |
def hoge | |
puts 'M1' | |
end | |
end | |
module M2 | |
def hoge | |
puts 'M2' | |
end | |
end | |
class C | |
include M1 | |
prepend M2 | |
end | |
a = C.new | |
a.hoge #=> ? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment