In message <D02D2719-35E5-4A0D-9D47-EEDA619A0739 / aribrown.com>, Ari Brown writes:
>newbie question pertaining  to class level variables:

>What's the difference between @foo and @@foo? Is there even a  
>difference?

@foo = instance variable; each instance has one
@@foo = class variable; only one shared among all class members

	class Example
	  def print
	    puts @y, @@z
	  end
	  def initialize(x)
	    @y = x
	    @@z = x
	  end
	end
	e1 = Example.new(1)
	e2 = Example.new(2)
	e1.print
	e2.print

The first print prints 1 and 2, the second prints 2 and 2.  The first
new sets e1.y to 1, and Example.z to 1.  The second sets e2.y to 2,
and Example.z to 2.  There's only one @@z (also called "Example.z"), but
there's one @y for each instance.

-s