title: Ruby, class variables and inheritance ? super class @@var gets changed?
body: <p>Any Ruby guru that explain this?</p>
  
  <pre><code>class Bar
    @@x = 10
    def self.test
      return @@x
    end
  end
  
  class Foo &lt; Bar
    @@x = 20  
  end
  
  
  puts Bar.test  # 20 why not 10?
  puts Foo.test  # 20 
  </code></pre>
  
  <p>When i run this from TextMate. I would expect that</p>
  
  <pre><code>puts Bar.test returns 10
  </code></pre>
  
  <p>and </p>
  
  <pre><code>puts Foo.test returns 20
  </code></pre>
  
  <p>But for some reason (that i would love to know) @@x in Foo updates Bar as-well, which is the super class. What is it i'm missing?</p>