From: ara.t.howard@... Date: 2006-03-11T05:10:33+09:00 Subject: Re: Using 'include' but not poluting my namespace On Sat, 11 Mar 2006, Mike Austin wrote: > I noticed that if you 'include' a module within a method, it will polute the > namesapce that defines that method. I found a simple solution is to declare > a throw-away class, and execute my code in that. Is there a more better way > to achieve this? > > # Pollutes current namespace > def init() > include Inertia > > do_stuff_with_inertia() > end > > # Doesn't polute namespace, but ugly > class DontPolute > include Inertia > > do_stuff_with_inertia() > end > > > Mike > both pollute your namespace equally. the first pollutes class Object, the second class DontPolute. remember that you're code in ruby, if not inside a class, is inside the Object class. this allows you to pretend your coding something like perl. i always write main programs like so class Main ... end Main::new if $0 == __FILE__ to avoid any such issues. if you are looking for a workaround you can also use Module::new{ include Inertia ... } regards. -a -- knowledge is important, but the much more important is the use toward which it is put. this depends on the heart and mind of the one who uses it. - h.h. the 14th dali lama