From: "Bram S." Date: 2013-06-05T20:56:33+09:00 Subject: Re: Cannot access constants from included modules in a submodule Kendall Gifford wrote in post #1111199: > On Mon, Jun 3, 2013 at 9:38 AM, Bram S. wrote: >> Now if the SubBarModule's ancestors do not include FooModule, I can >> understand that it cannot access Foo, but on the other hand, >> SubBarModule's ancestors do not include BarModule either, so why can it >> acces Bar? >> > > "Constants are looked up in the lexical scope in which they were > referenced." (Programming Ruby 1.9, page 290) > > Accessing the constant Bar works above because the constant is available > based on the lexical scope (it's defined in an enclosing module > definition). So, its availability has nothing to do with inheritance. If > you really want a set of constants to be available to a module and all > modules nested/namespaced within it, just define said constant in the > outermost module that needs access. Okay, I see how this works now. Thanks for your clarifications! Bram Senders bupknar@gmail.com -- Posted via http://www.ruby-forum.com/.