Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Module#autoload

mod.autoload(module, filename) → nil

Registers filename to be loaded (using Kernel::require) the first time that module (which may be a String or a symbol) is accessed in the namespace of mod.

Example
module A
end
A.autoload(:B, "b")
A::B.doit            # autoloads "b"
See also #autoload? #attr_writer #attr_reader #class_eval also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0