From: Avi Bryant Date: 2001-03-12T11:20:46+09:00 Subject: [ruby-talk:12448] Re: class variables On Mon, 12 Mar 2001, Kent Dahl wrote: > > class A > @@A_VAR = {'A'=>1} > > def A.getVAR #dynamic method calling on the class object > @@A_VAR > end Or (requires 1.7.0, I think): class A var = {'A'=>1} define_method(:getVAR) {var} end Note that this leaves you with an instance method getVAR instead of a class method (which I find more convenient). I tend to use this approach instead of class variables, when possible.