X
Xavier Noria
According to my trials nor Module#constants neither Module#const_get
work with constants defined in enclosing modules:
module M
C = 1
module N
C # -> 1
end
end
M::N.constants # -> []
M::N.const_get("C") # -> NameError
Looks as if they only took into account ancestors.
But the Pickaxe says that Module#constants:
"Returns an array of the names of the constants accessible in mod.
This includes the names of constants in any included modules (example
at start of section)."
Does "This includes" mean "These are"? Is there a way to obtain "M::C"
as qualified name of a constant visible by N?
-- fxn
work with constants defined in enclosing modules:
module M
C = 1
module N
C # -> 1
end
end
M::N.constants # -> []
M::N.const_get("C") # -> NameError
Looks as if they only took into account ancestors.
But the Pickaxe says that Module#constants:
"Returns an array of the names of the constants accessible in mod.
This includes the names of constants in any included modules (example
at start of section)."
Does "This includes" mean "These are"? Is there a way to obtain "M::C"
as qualified name of a constant visible by N?
-- fxn