From: "David A. Black" Date: 2004-02-16T11:29:53+09:00 Subject: Re: inheritence of class vars Hi -- On Mon, 16 Feb 2004, Florian G. Pflug wrote: > On Sat, Feb 14, 2004 at 10:44:04AM +0900, 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 > > Might be me being stupid.. but if these new rules are in place, what will > the difference between class variables and instance variables (of class > objects) be? > > The only thing coming to my mind, is that class variables are easily > accessed from instance methods, while you need to do > "self.class.class_eval{@my_class_instance_var}" for class-object instance > variables. I think that's the main difference, at least in terms of usage. That's what makes me have doubts about it; I'm not sure what purpose class variables will serve except to save some typing. > BTW: Just for the sake of being curious... is it possible to define > class-variables of the class Class? Sure, you can do this: class Class @@x = 1 end David -- David A. Black dblack@wobblini.net