Roger Pack wrote: > class A > @@a = 3 > end > > class B < A > def go > @@a > end > end > > in B.new.go => 3...where is @@a stored?...it's not in B...it's not in > A's nearest ancestor, which is "Object"...it's special cased somehow? I believe it's picking up the value from class A, since that's B's ancestor, and B doesn't already have an @@a of its own. It gets scarier though. Have a look at this: >> class A >> def a >> @@a >> end >> def a=(v) >> @@a = v >> end >> end => nil >> class B < A >> def a2 >> @@a >> end >> def a2=(v) >> @@a = v >> end >> end => nil >> ai = A.new => #<A:0x7f59fb532260> >> bi = B.new => #<B:0x7f59fb52cbf8> >> bi.a2 = 1 => 1 >> ai.a NameError: uninitialized class variable @@a in A from (irb):3:in `a' from (irb):23 from :0 >> bi.a NameError: uninitialized class variable @@a in A from (irb):3:in `a' from (irb):24 from :0 >> bi.a2 => 1 >> bi.a = 2 => 2 >> ai.a => 2 >> bi.a => 2 >> bi.a2 => 1 >> ai.a = 3 => 3 >> ai.a => 3 >> bi.a => 3 >> bi.a2 => 1 So which 'version' of the @@a class variable you see, depends on where the method which reads it was defined... or something like that. -- Posted via http://www.ruby-forum.com/.