Kernel#autoload
Kernel#autoloadã§ä»»æã®å®æ°ãåç §ããå ´åã«ãæå®ãããã¡ã¤ã«ãrequireããããã«è¨å®ã§ãã¾ãã
# å®æ°Fooãåç §ããå ´åã«ãfooãrequireãã autoload :Foo, "foo" module Var # å®æ°Var::Hogeãåç §ããå ´åã«ãvar/hoge ãrequireãã autoload :Hoge, "var/hoge" end Foo Var::Hoge
foo.rbã¨var/hoge.rbã¯ä»¥ä¸ã
module Foo; end puts "foo"
module Var module Hoge end end puts "hoge"
å®è¡çµæã§ãã
foo hoge
ãã¼ããããã¡ã¤ã«ãæå°å(å¿ è¦ã«ãªãã¾ã§ãã¼ãããªã)ããã¨ãã«ä½¿ãã¿ããã§ããããµãã