Skip to content

Instantly share code, notes, and snippets.

@kodaitakahashi
Last active October 16, 2016 07:22
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/4a85808855aa5944dfb965608510fa05 to your computer and use it in GitHub Desktop.
Save kodaitakahashi/4a85808855aa5944dfb965608510fa05 to your computer and use it in GitHub Desktop.
extendの説明
module M
def hoge
puts 'hoge'
end
end
class C
extend M
end
C.hoge #=> hoge
C.ancestors #=>[C, Object, PP::ObjectMixin, Kernel, BasicObject]
a = C.new
a.hoge #=> NoMethodError: undefined method `hoge'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment