From: dblack@... Date: 2003-05-21T23:59:07+09:00 Subject: Re: module constant access Hi -- On Wed, 21 May 2003, Dan Janowski wrote: > > On Wednesday, May 21, 2003, at 10:25 America/New_York, ts wrote: > > >>>>>> "D" == Dan Janowski writes: > > > > D> irb(main):013:0> module Trouble > > > > When you write this, this is like if you write > > > > Trouble = Module.new > > > > Sure. This makes sense. But why the difference in visibility of the > constant Trouble? It's not exactly visibility -- const_defined? tells you whether that constant was/is defined in that module, not just whether the module can see it. For example: irb(main):001:0> class A; X = 1; end => 1 irb(main):002:0> class B < A; end => nil irb(main):003:0> B::X => 1 irb(main):004:0> A.const_defined?("X") => true irb(main):005:0> B.const_defined?("X") => false irb(main):006:0> class B; X = 2; end => 2 irb(main):007:0> B.const_defined?("X") => true David -- David Alan Black home: dblack@superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav