From: "David A. Black" Date: 2007-09-29T20:13:06+09:00 Subject: Re: Curious include behavior Hi -- On Sat, 29 Sep 2007, 7stud -- wrote: > David A. Black wrote: >> Hi -- >> >> On Sat, 29 Sep 2007, 7stud -- wrote: >> >>> David A. Black wrote: >>>> >>>> At the top level, the include will include the module in Object: >>>> >>> >>> Where is the module before it is included? >> >> I'm not sure what you mean. Can you elaborate? >> >> >> David > > I would think the name Foo would be visible just like the name of a > method is visible, e.g.: > > def greet > puts "hello" > end > > According to pickaxe2 p. 346, greet is inserted as a private method of > Object, and hence can be called in any context without a receiver, i.e. > without 'some_obj." in front of the method name. > > In the op's example, there is a module named Foo. Is Foo just a free > floating object? Or, is it an attribute of some omnipresent object? Constants you define at the top level are owned by Object: class C end module M end X = 1 p Object.constants.grep(/^(C|M|X)$/) # => ["X", "C", "M"] David -- Upcoming training from Ruby Power and Light, LLC: * Intro to Ruby on Rails, Edison, NJ, October 23-26 * Advancing with Rails, Edison, NJ, November 6-9 Both taught by David A. Black. See http://www.rubypal.com for more info!