From: Jim Weirich Date: 2003-04-08T10:03:45+09:00 Subject: Re: @@class variables and subclasses On Mon, 2003-04-07 at 20:42, Ryan Pavlik wrote: > OK, this has been causing me problems: > > class A > @@index = Index.new(...) > end #c:A > > > class B < A > @@index = Index.new(...) > end #c:B Try this ... class A class << self attr_accessor :index end def f self.class.index = Index.new # or A.index end end And if B inherits from A, it A.index and B.index are independent. -- -- Jim Weirich jweirich@one.net http://w3.one.net/~jweirich --------------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)