From: Gary Wright Date: 2009-07-23T05:19:38+09:00 Subject: Re: Instantiating classes / sharing data between classes On Jul 22, 2009, at 3:15 PM, Trevoke wrote: >> >> I don't recommend class variables because their actual scope >> is very non-intuitive (class hierarchy scope, not class scope) >> and they add to the semantic load of a design when plain >> old instance variables (on the class object) will do just fine. >> >> Gary Wright > > Gary -- these values ARE the same for EVERY SINGLE INSTANCE of the > class, and are not meant to be changed. > In this particular instance, are class variables fulfilling their > destiny? Here is a nice discussion of the confusion that surrounds 'class variables' and 'class instance variables' in Ruby: Most people expect Ruby's class variables to behave like Java or C++'s class variables but that is an incorrect assumption. In Ruby, "instance variables of a class" are most closely analogous to 'class variables' in Java or C++ and should generally be used instead of Ruby's 'class variables'. Gary Wright