What I understand from require statement is that the argument to it is a
file, where as include requires module/class name.
But once I do a require for a specific ruby file which has various
and classes, doesn’t these classes/modules get included automatically?
infact they do get automatically as I have tried doing so.
But in various files of ruby library I found that people use include
“modulename” after a require statement for the file which contains that
Jatinder S. wrote:
Require is purely used to ‘embed’ files in other files.
Include is used on modules, and adds so-called “MixIn”-functionality.
It means you “import” the methods of the given Module into the current
class (or Module?).
So, basically, you have a Module that provides some semi-generic
functionality, then you have a class that wants to take advantage of
foo = B.new
I hope this helps!
Ps. this explanation might be horrible, and it might be wrong; I’m not a