title: Ruby class instance variable vs. class variable
body: <p>I read <a href="http://archive.today/dCYNj" rel="noreferrer">https://stackoverflow.com/questions/826734/when-do-ruby-instance-variables-get-set</a> but I'm of two minds when to use class instance variables.</p>
  <p>Class variables are shared by all objects of a class, Instance variables belong to one object. There's not much room left to use  class instance variables if we have class variables.</p>
  <p>Could someone explain the difference between these two and when to use them?</p>
  <p>Here's a code example:</p>
  <pre><code>class S
    @@k = 23
    @s = 15
    def self.s
      @s
    end
    def self.k
       @@k
    end
  
  end
  p S.s #15
  p S.k #23
  </code></pre>
  <p><strong>Update:</strong> I understand now! Class Instance Variables are not passed along the inheritance chain.</p>