I am experimenting with the Ruby include
keyword as shown below:
module A
def show
puts "working"
end
end
include A
class E
end
class D
end
e = E.new
d = D.new
e.show
d.show
o = Object.new
puts o.respond_to?("show")
******************************output****************
working
working
true
I was expecting output to be undefined method
but it's giving me the proper output. I have also observed that the show
method defined in module A
is becoming an instance method of Object
.
Why are these methods becoming instance methods of the class Object
?
Please help in understanding this concept.