Skip to content

Instantly share code, notes, and snippets.

@kodaitakahashi
Created October 16, 2016 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kodaitakahashi/46f746888539c65d29551896b1186070 to your computer and use it in GitHub Desktop.
Save kodaitakahashi/46f746888539c65d29551896b1186070 to your computer and use it in GitHub Desktop.
includeとprependを使ったメソッド探索
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]
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