Ruby | include x extend
Module A
def say
puts "Hello! I'm module A"
end
end
class B
include A
end
class C
extend A
end
Class method
B.say produces: undefined method 'say' for B:Class
C.say produces: this is module A
Instance method
B.new.say produces: this is module A
C.new.say produces: undefined method 'say' for C:Class
Written by Débora Fernandes
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#