On Wed, 30 Mar 2005 05:30:04 +0900, Austin Ziegler <halostatue / gmail.com> wrote: > On Wed, 30 Mar 2005 05:03:48 +0900, B. K. Oxley (binkley) > <binkley / alumni.rice.edu> wrote: > > Florian Gross wrote: > > > class Meta > > > def self.has_many(sym) > > > ivar = :"@#{sym}" > > > define_method(sym.to_sym) do > > > new_value = instance_variable_get(ivar) || [] > > > instance_variable_set(ivar, new_value) > > > new_value > > > end > > > end > > > end > > What is the difference between these two approaches? > > Florian's will only work on Ruby 1.8 or later and avoids some of the > concerns that people have around "eval". > > -austin So does there exist (as I cannot find it) a way to access @@vars via symbols in a similar manner? @vars tied to the class are easy enough (and can often fill the same niche), but I cannot find a method similar to instance_variable_XXX for @@ vars. Thanks Patrick