From: "David A. Black" Date: 2004-09-15T07:48:52+09:00 Subject: Re: Modules as namespaces [re-sending an answer that didn't seem to make it for some reason] Hi -- On Wed, 15 Sep 2004, Sam Stephenson wrote: > I'm trying to nest modules to create namespaces, but I'm not having > much luck. Let's say I have > > | module A > | module B > | def foo; @foo end > | end > | end > | > | class Foo > | include A > | def initialize; @foo = 'foo' end > | def bar; B::foo end > | end > > Calling Foo#bar raises "NoMethodError: undefined method `foo' for > A::B.Module". I would like to get "foo". What am I doing wrong? The notation B::foo mean's B's own foo method: module B def B.foo puts "hi" end end B::foo # hi To get your Foo object to have the method B#foo in its path, you'd have to include the module (A::B) in Foo, or extend your object with it. David -- David A. Black dblack@wobblini.net