From: dblack@... Date: 2007-07-27T05:22:53+09:00 Subject: Re: Class variables and how to set them up only once. Hi -- On Fri, 27 Jul 2007, Kyle Schmitt wrote: > Right, so the way I wrote previously, or this way: > > def setupLogger(path="c:\\#{DateTime.now.to_s.gsub(':','-')}.xml") > unless self.class.class_variables.include?"@@logger" > puts "I'm setting up the logger, you should only see me once" > @@logger=File.new("c:\\#{DateTime.now.to_s.gsub(':','-')}.xml","w") > @@logger.puts "" > @loggerSetup=true > end > end What about: @@logger ||= File.new .... David -- * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.com)