From: Gregory Seidman Date: 2008-02-29T06:21:41+09:00 Subject: Re: constants defined in Kernel are also defined in Object? On Fri, Feb 29, 2008 at 06:08:38AM +0900, Joel VanderWerf wrote: > Gregory Seidman wrote: >> On Fri, Feb 29, 2008 at 02:17:33AM +0900, Paul Brannan wrote: >>> This seems peculiar to me: >>> >>> cout@bean:~/tmp$ ruby -e 'module M; FOO = 42; end; class Foo; include M; end; p Foo.const_defined?(:FOO)' >>> false >>> cout@bean:~/tmp$ ruby -e 'Kernel.const_set(:FOO, 42); p Object.const_defined?(:FOO)' >>> true >>> cout@bean:~/tmp$ ruby -e 'Kernel.const_set(:FOO, 42); p Class.const_defined?(:FOO)' >>> false >>> >>> Is there a reason for this behavior? >> >> % ruby -e 'p Object.ancestors' >> [Object, Kernel] >> % >> >> Kernel is included by Object. > > And M is included by Foo, yet the analogy breaks down in the outputs of > > Object.const_defined?(:FOO) > > Foo.const_defined?(:FOO) Hunh. I didn't read closely. A little playing in irb reveals the same thing. That's odd. I have no answer for you. > vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407 --Greg