From: Martin Weber Date: 2003-08-21T18:55:44+09:00 Subject: Re: Class variables - a surprising result On Thu, Aug 21, 2003 at 06:33:09PM +0900, Jason Williams wrote: > class Sup > @@x = "A" > def test > print @@x > end > end > > class Sub1 < Sup > @@x = "B" > end > > class Sub2 < Sup > @@x = "C" > end > > Sup.new.test > Sub1.new.test > Sub2.new.test > > > I expect this to print "ABC", and yet it prints "CCC". Why is this? Class variable allocation is per class scope, not per subclass scope. Sub1, Sub2 and Sup really do share their class variables. Now don't ask me for the "why exactly"... -Martin