Nobuyoshi Nakada
9/21/2006 3:40:00 AM
Date: Thu, 21 Sep 2006 02:06:56 +0900
Posted: Wed, 20 Sep 2006 18:06:54 +0100
From: "Chris Roos" <chrisjroos@gmail.com>
Reply-To: ruby-talk@ruby-lang.org
Subject: const_defined? not quite in sync with const_get ??
To: ruby-talk@ruby-lang.org (ruby-talk ML)
Message-Id: <3a5e51050609201006j5dc6449cyae74e71099fb3f52@mail.gmail.com>
X-ML-Name: ruby-talk
X-Mail-Count: 215393
2006/9/21, Chris Roos <chrisjroos@gmail.com>:
> Assuming the following snippet, I'd expect Foo::const_defined?(:Bar)
> to be routed via Foo::const_missing. Instead it resolves to top-level
> Bar. Can someone explain why please?
>
> --code--
>
> class Bar
> end
>
> module Foo
> def self.const_missing(konst)
> puts "missing konst #{konst}"
> end
> end
>
> Foo::Bar
> #=> missing konst Bar # Unsurprising behaviour
>
> p Foo::const_defined?(:Bar)
> false # Unsurprising behaviour
>
> p Foo::const_get(:Bar)
> #=> Bar # Surprising behaviour
>
> --/code--
>
> Cheers,
>
> Chris
>
>
--
??????
--
--- ????Bug????
--- ?????Bug?????
?? ??