From: 7stud -- Date: 2009-08-18T20:22:54+09:00 Subject: Re: Including a module in an included module. Prince Nez wrote: > module M1; end > module M2; include M1; end > module M1; DOG = :woof; end > module M2; DOG; end > # => :woof > > I can add to a module after it has been included. Neat. > > module M1; DOG = :woof; end > module M2; include M1; end > module M3; include M2; end > module M3; DOG; end > # => :woof > > Including a module seems to give me any modules that it includes. Swish. > > module M2; end > module M3; include M2; end > module M1; DOG = :woof; end > module M2; include M1; end > module M3; DOG; end > # => NameError: uninitialized constant M3::DOG > > So I assumed I'd be able to include a module in a module after it has > been included, if you get my drift. It surprises me that this dog > doesn't bark. The results seem to speak for themselves: include only unwraps the namespace name from the names that were in the module at the time the module was included--subsequently adding constants to the previously included module does not present them unwrapped. -- Posted via http://www.ruby-forum.com/.