Gregory Seidman
2/28/2008 9:22:00 PM
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