David A. Black wrote: > Class variables, at least through 1.8.x, are essentially per-hierarchy > and not per-Class-object. For 1.9/2.0, though, Matz has presented the > following new rules: > > * class variables will be local to the class/module > * if you need to access class variables from outside, > define accessors The per-hierarchy thing was never very clear. Just _which_ hierarchy a variable belongs to depends on the order in which it is first assigned: class A; end class B < A; end # Try switching the following two lines! class A; @@x = "A"; end class B; @@x = "B"; end class A; puts "In A, @@x = #{@@x}"; end class B; puts "In B, @@x = #{@@x}"; end Before switching the lines, there is one @@x for the hierarchy consisting of A and B. After switching, there is one @@x for A and _another_ @@x for B and its descendants. It makes sense, but it's an easy place to get tripped.