From: Christian Szegedy Date: 2002-09-06T20:10:27+09:00 Subject: Re: Class variables and inheritance Philipp Meier wrote: > Hallo rubyers, > > I'm a little puzzled with Class variables (@@foo) and inheritance: > > class Super > @@foo = [] > > def self.manipulate(arg) > @@foo << arg > end > > def get_foo > @@foo > end > end > > class Sub1 < Super > > manipulate "first" > > end > > class Sub2 < Super > manipulate "second" > end > > Sub1.new.get_foo # => ["first","second"], wanted "first" > Sub2.new.get_foo # => ["first","second"], wanted "second" > How about this? class A def self.add(x) (@foo||=[])<