From: cjon@... (Cullen J O'neill) Date: 2001-03-14T03:40:01+09:00 Subject: [ruby-talk:12579] Re: class variables Kent Dahl (kentda@stud.ntnu.no) wrote: : As for an attempt at accomplishing what you were after, try this hack: : : class A : @@A_VAR = {'A'=>1} : : def A.getVAR #dynamic method calling on the class object : itself : @@A_VAR : end : : def A.new : puts getVAR : end : : def initialize : end : : end : : class C < A : @@C_VAR = {'C'=>1} : def C.getVAR : @@C_VAR : end : : end : : class B < A : @@B_VAR = {'B'=>1} : def B.getVAR : @@B_VAR : end : end : : b=B.new : c=C.new : a=A.new : Why not this instead? class A @VAR = {'A'=>1} def A.var @VAR end def initialize puts self.class.var end end class C < A @VAR = {'C'=>1} end class B < A @VAR = {'B'=>1} end b=B.new c=C.new a=A.new Cullen J O'Neill -- cjon@engin.umich.edu