Skip to content

Instantly share code, notes, and snippets.

@kodaitakahashi
Created October 16, 2016 06:50
Show Gist options
  • Save kodaitakahashi/8feb03898e4781f2f0f45d5442cbbac0 to your computer and use it in GitHub Desktop.
Save kodaitakahashi/8feb03898e4781f2f0f45d5442cbbac0 to your computer and use it in GitHub Desktop.
prependの説明
module M
class hoge
puts 'hoge'
end
end
class C
prepend M
end
a = C.new
a.hoge #=> hoge
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