Hi, >> AAAAAAAHHHHHHHHH!!!!!!!!!!!! >> I've been playing with this the whole night. I am not gonna stop >> until I've finished writing a clear document that explains >> absolutely everything. > I think Matz is planning to change class variables in 2.0 so that they > are class/module scoped rather than hierarchy scoped. Meanwhile, > here's another fun variant: > > class A > end > > class B < A > @@var = 10 > def self.var > @@var > end > end > > class A > @@var = 20 > def self.var > @@var > end > end > > p A.var > p B.var The result is: 20 10 Oh dear... let me guess. To start with, the class A doesn't have @@var defined. Class B is defined, and @@var is allocated. B will share @@var with all of its children. Then, A happened to be extended and @@var is allocated. It will share @@var with its children, but NOT B. The compiler smells something fishy there, and says: ./p.rb:9: warning: class variable @@var of A is overridden by B Which is what happens: effectively, the hierarchy rule is NOT going to be satisfied. I love Ruby, but this is so error-prone it's not funny :-| Merc.