We love to share with you all we know about Ruby. And we like to help others to learn something new. So, let’s learn about the autoload Method in Ruby today?
Module#autoload method registers a file path to be loaded the first time that a specified module or class is accessed in the namespace of the calling module or class.
Module#autoload?is in charge of checking if a registered module/class in a specific namespace has already been loaded or not.
It’s also used for checking if a module is registered (or not) as autoload in a specific namespace.
- When the
Module#autoloadmethod is called within a specific namespace then the module/class and the file path given as arguments of the method are stored in an internal hash table.
Let’s have a look at the examples here.
And by the way, what do you know about inheritance in Ruby? Because we are ready to help you get to know more about it.
In case, you’re looking for experienced Ruby developers, ask Syndicode!