From: Daniel Sheppard Date: 2004-04-07T09:13:34+09:00 Subject: Re: Different types of include I left out a line in each example: MyModule::MyClass.new.hello which succeeds in the first case, but cannot find FXTreeList in the second. > -----Original Message----- > From: Daniel Sheppard > Sent: Wednesday, 7 April 2004 10:10 AM > To: ruby-talk ML > Subject: Different types of include > > > How is an 'include' outside of a module different from one > inside a module. Where does the outer 'include' come from > (the only documented include method is on Module). > > The following code works: > > require 'fox' > include Fox > module MyModule > class MyClass > def hello; puts FXTreeList; end > end > end > > The following does not: > module MyModule > require 'fox' > include Fox > class MyClass > def hello; puts FXTreeList; end > end > end > > I was under the impression that part of the mechanism of > include was to include the constants defined in the other module. > > Is the only way to keep your namespace clean to use > Fox::FXTreeList everywhere and avoid top-level includes? > > (this isn't a problem with fox, due to the fact that fox > always has FX on the classname prefix, but I can see that it > could be a problem with other modules). > > Daniel Sheppard > http://jroller.net/page/soxbox > ############################################################## > ####################### > This email has been scanned by MailMarshal, an email content > filter. > ############################################################## > ####################### > > ##################################################################################### This email has been scanned by MailMarshal, an email content filter. #####################################################################################