From: Sean Chittenden Date: 2002-04-01T08:17:28+09:00 Subject: Re: Detecting class variables.... > > I have a class that will have many objects and each object has a > > rather expensive regexp that I don't want to recompile every instance. > > I was hoping to do something similar to: > > > > if @@httpd_combined_entry_re.nil? > > @@httpd_combined_entry_re = Regexp.new('some regexp string') > > end > > > > > > Without using Modules#class_variables, there anyway to see if the > > symbol for a class variable is populated? -sc > > Could you get by with the ||= assignment idiom? > > @@class_var ||= Regexp.new('...') Nope. :46:in `initialize': uninitialized class variable @@httpd_combined_entry_re in Logs::Httpd::Combined::Entry (NameError) -sc -- Sean Chittenden