From: Paul McMahon Date: 2008-06-11T15:26:46+09:00 Subject: Re: accessing class variables from the outside (beginner question) > if you want a variable available to all instances that says how many > instances exist. If you want to create an ID that increments with > each instance. If you are storing a path that may change, but all > instances will use it. If you want to update scaling criteria on > several objects at once, having a class variable set to twips, pixels, > or inches could be just the right tool. And on and on and on...... Perhaps I wasn't clear enough. As far as I know, you can accomplish all that using class level instance variables. For example, consider the following code: class ClassLevelVariables @instance_count = 0 class << self attr_accessor :instance_count end def initialize ClassLevelVariables.instance_count += 1 end end class ClassVariables @@instance_count = 0 class << self def instance_count @@instance_count end end def initialize @@instance_count += 1 end end [ClassLevelVariables, ClassVariables].each do |klass| puts klass.instance_count klass.new puts klass.instance_count end The code is almost equivalent, and I was just wondering when one style is prefered over the other.