Wolfgang N?dasi-Donner wrote:

> The class variable ("@@") belongs to the class object, while the instance
> variable (@) belongs to the instanciated object. A short example. May be you
> want to count how many objects are created based on a class. If you want to
> avoid global variables ($), which is a very good decision, you can use class
> variables. Using instance variables will not work.

It will. Note that the poster said "class instance variable" which is 
the instance variable of a Class. Classes are instances of Class and 
Class inherits from Module which inherits from Object so classes are 
objects as well:

class Foo
   @counter = 0
   class << self
     attr_accessor :counter
   end

   def initialize()
     self.class.counter += 1
   end
end

Foo.counter # => 0
5.times { Foo.new }
Foo.counter # => 5