From: Peter Hickman Date: 2002-12-04T19:39:11+09:00 Subject: Class variables problem I have used class Test def Test.Calc(x) return x * 2 end end class Fred < Test end puts Fred.Calc(12) which return 24 and is what I expected. But what I wanted to do was class Test def Test.Calc(x) return @@rate * x end end class Fred < Test @@rate = 10 end puts Fred.Calc(12) which s2:3:in `Calc': uninitialized class variable @@rate in Test (NameError) from s2:11 Now the class method has been inherited (and named accordingly) and I was expecting it to use the class variable as defined in Fred but it was trying to pick up the class variable in Test. How can I have the inheritence of a class method that accesses the class variable of the child class? This is a gross simplification, the class I am designing would really benefit from this working as I hoped. Oh yes. I am using ruby 1.6.7 (2002-03-19) [i386-linux] Any pointers greatly appreciated.