This is strictly theoretical.
module BleeTest
def meth
puts 'foo'
end
end
This code runs without error, but is it ever possible the invoke the method “meth”?
It seems to me that “meth” is an instance method of a module which cannot be instantiated. But then why is this construct allowed by the interpreter?
Yes, of course. You can mix
BleeTestinto an object:Or you can mix
BleeTestinto a class:In fact, the first form can also be expressed in terms of the second form:
That is, after all, the whole point of modules in Ruby: to serve as mixins in order to compose objects and classes.