Mehr, Assaph (Assaph) wrote:
>>Then perhaps Ruby should not provide a "nice" way to access @@var too
> 
> :-)
> 
> Ruby's all about niceness :-)
> (Sorry for the preaching tone earlier). I really liked Ara's solution
> with (semi-constant) class variables. Why is @@var failing you, and you
> have to use class@var instead?

Simply because @@var is shared between subclasses.

  $ irb
  irb(main):001:0> class Parent; @@var=1; def p_var; p @@var end end
  => nil
  irb(main):002:0> class Child < Parent; @@var = 2 end
  => nil
  irb(main):003:0> Parent.new.p_var
  2
  => nil

I know there might be some cases where you want to share your class vars 
with the subclasses, but I usually want a per-class class variables.

I believe this will change in Ruby2.

-- 
dave