From: Nobuyoshi Nakada Date: 2006-09-21T12:39:33+09:00 Subject: Re: const_defined? not quite in sync with const_get ?? Date: Thu, 21 Sep 2006 02:06:56 +0900 Posted: Wed, 20 Sep 2006 18:06:54 +0100 From: "Chris Roos" 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 : > 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はできる。 中田 伸悦