From: Joel VanderWerf Date: 2009-04-23T07:50:41+09:00 Subject: Re: hygienic startup file Thomas Hafner wrote: > Hello, > > a startup file to be loaded by RUBYOPT should have minimal side > effects. I guess, this pattern will do it: > > class << Object.new > FOO = ... # will not override FOO if defined before > BAR = ... # will introduce BAR intermediately > ... > # Use the constants above to do some wanted side effect on an > # object hold by a global variable, e.g. $LOAD_PATH : > $:.unshift(FOO, ...) > end > # no more BAR visible here > > Is there a canonical way to achive this kind of hygiene? > > Regards > Thomas Can't you use local variables to do the same thing? foo = ... $:.unshift foo -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407