From: Robert Klemme Date: 2004-06-10T20:03:37+09:00 Subject: Re: Who own the constants? "rolo" schrieb im Newsbeitrag news:ACEPLIKLBKEMDDIELPKIGEPICGAA.rohitlodha@hotwireindia.com... > Hi > > Who keeps the constants defined within a Module of the Class? What do you mean by "Module of the Class"? > The Class in which it is defined or the last module in the class hierarchy ? Constants are always owned by the module or class they are defined in although they are accessible from modules / classes that inherit the defining class: >> module Mod; BAR = "hello"; end => "hello" >> Mod::BAR => "hello" >> class Foo; include Mod; FOO = "world"; end => "world" >> Foo::FOO => "world" >> Foo::BAR => "hello" >> Mod::FOO NameError: uninitialized constant Mod::FOO from (irb):6 >> Foo.ancestors => [Foo, Mod, Object, Kernel] >> Foo.constants => ["BAR", "FOO"] >> Mod.constants => ["BAR"] Regards robert