Created
October 16, 2016 06:50
-
-
Save kodaitakahashi/8feb03898e4781f2f0f45d5442cbbac0 to your computer and use it in GitHub Desktop.
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 M | |
class hoge | |
puts 'hoge' | |
end | |
end | |
class C | |
prepend M | |
end | |
a = C.new | |
a.hoge #=> hoge |
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 | |
class hoge | |
puts 'hoge' | |
end | |
end | |
class C | |
prepend M | |
end | |
C.ancestors #=>[M, C, Object, PP::ObjectMixin, Kernel, BasicObject] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment