From: Gary Wright Date: 2009-03-03T07:05:01+09:00 Subject: Re: Delegating class methods On Mar 2, 2009, at 9:24 AM, lasitha wrote: > There is a school of thought that eigenclass [1] instance variables > are generally preferred over @@class_variables. Folks coming to ruby > from other languages often miss the distinction but you'll find many > exposés on this [2], including in the Pickaxe. > > I personally like eigenclass variables - they provide all the > capability of class variables, fit elegantly into ruby's object model > and follow all the rules of instance variables. So i don't ever bother > with class vars. I don't think I've ever seen the term 'eigenclass variables' used in this way. Every object has instance variables. Classes are objects and so they have instance variables. There is no need to talk about eigen classes (or the more common term, singleton classes) when you are talking about alternatives to class variables. The main confusion with Ruby class variables comes from: -- Ruby class variables have syntax similar to instance variables but much different semantics -- Ruby class variables are assumed to be analogous to C++ class variables (or Java class variables) but that is the wrong analogy. Ruby instance variables of class objects is the more appropriate comparison. It would be nice if there was a common term for 'instance variables of class objects' but 'eigenclass variables' isn't it. Gary Wright