зеркало из https://github.com/github/ruby.git
Specify Kernel#autoload? uses current namespace
Because Kernel#autoload? uses the current namespace, it can lead to potentially confusing results. We should make it clearer that modules count as separate namespaces to lookup in. Co-authored-by: Jeremy Evans <code@jeremyevans.net> Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
This commit is contained in:
Родитель
733d50f0a5
Коммит
1984f9aedc
14
load.c
14
load.c
|
@ -1532,10 +1532,22 @@ rb_f_autoload(VALUE obj, VALUE sym, VALUE file)
|
|||
* autoload?(name, inherit=true) -> String or nil
|
||||
*
|
||||
* Returns _filename_ to be loaded if _name_ is registered as
|
||||
* +autoload+.
|
||||
* +autoload+ in the current namespace or one of its ancestors.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
|
|
Загрузка…
Ссылка в новой задаче