Class variables seem to mar the uniformity of the Ruby class model,
since they have different behavior from instance variables of class
objects ("class instance variables" in Smalltalk, where every subclass
has its own copy).  Is there a good reason for this, other than giving
instance methods an easy way to access variables in the class?

Just to make the distinction between these two types of variables
clear:

class A
  @@var = "A"
  @var = "A"
end 

class B < A
  @@var = "B"
  @var = "B"
end

p A.class_eval("@@var") #=> "B"
p A.class_eval("@var") #=> "A"

"Aleksei Guzev" <aleksei.guzev / bigfoot.com> wrote in message news:<u_P37.19954$u76.948686 / e420r-atl3.usenetserver.com>...
> Why class variables are shared by subclasses?
> 
> 	class A
> 	   @@cv = 3
> 	   def A.ppp
> 	      p @@cv
> 	   end
> 	end
> 
> 	A.ppp
> 
> 	class B < A
> 	   def B.t
> 	      @@cv = 5
> 	   end
> 	end
> 
> 	A.ppp
> 	B.t
> 	A.ppp
> 
> 	class C < A
> 	   @@cv = 7
> 	end
> 
> 	A.ppp
> 	B.ppp
> 	C.ppp
> 
> Produces 
> 	3
> 	3
> 	5
> 	7	
> 	7
> 	7