Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

Kernel#autoload?

(::interned name) -> ::String?
autoload?(name, inherit=true) → String or nil

Returns filename to be loaded if name is registered as autoload in the current namespace or one of its ancestors.

Example
autoload(:B, "b")
autoload?(:B)            #=> "b"

module C
  autoload(:D, "d")
  autoload?(:D)          #=> "d"
  autoload?(:B)          #=> nil
end

class E
  autoload(:F, "f")
  autoload?(:F)          #=> "f"
  autoload?(:B)          #=> "b"
end
See also #autoload #binding #at_exit #block_given? also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0