N
Nathaniel Talbott
The new ability to declare a class nested in another module (or class)
without actually re-declaring the outer module is cool, BUT:
irb(main):001:0> module M
irb(main):002:1> CONST = "a"
irb(main):003:1> class C
irb(main):004:2> def m
irb(main):005:3> p CONST
irb(main):006:3> end
irb(main):007:2> end
irb(main):008:1> end
=> nil
irb(main):009:0> M::C::new.m
"a"
=> nil
irb(main):010:0> class M::C
irb(main):011:1> def m
irb(main):012:2> p CONST
irb(main):013:2> end
irb(main):014:1> end
=> nil
irb(main):016:0> M::C::new.m
NameError: uninitialized constant M::C::CONST
from (irb):12:in `m'
from (irb):16
Why does the second case fail? It makes me not want to use the second
version, since it means I have to fully-qualify all constants in the
enclosing namespace, instead of just using them as I usually do. I hope it's
just a bug :-/.
Nathaniel
<(><
without actually re-declaring the outer module is cool, BUT:
irb(main):001:0> module M
irb(main):002:1> CONST = "a"
irb(main):003:1> class C
irb(main):004:2> def m
irb(main):005:3> p CONST
irb(main):006:3> end
irb(main):007:2> end
irb(main):008:1> end
=> nil
irb(main):009:0> M::C::new.m
"a"
=> nil
irb(main):010:0> class M::C
irb(main):011:1> def m
irb(main):012:2> p CONST
irb(main):013:2> end
irb(main):014:1> end
=> nil
irb(main):016:0> M::C::new.m
NameError: uninitialized constant M::C::CONST
from (irb):12:in `m'
from (irb):16
Why does the second case fail? It makes me not want to use the second
version, since it means I have to fully-qualify all constants in the
enclosing namespace, instead of just using them as I usually do. I hope it's
just a bug :-/.
Nathaniel
<(><