title: Ruby craziness: Class vs Object?
body: <p>I just started playing with JRuby. This is my first ruby post. I had a hard time understanding classes vs objects in Ruby. It doesnt mean like what classes &amp; objects in other Object oriented laguages. for an example</p>
  
  <pre><code>Class.is_a? Object
  </code></pre>
  
  <p>returns <strong>true</strong>
  and</p>
  
  <pre><code>Object.is_a? Object
  </code></pre>
  
  <p><strong>too</strong>.</p>
  
  <p>so class &amp; Object are both objects</p>
  
  <p>here comes another one</p>
  
  <pre><code>Class.is_a? Class
  </code></pre>
  
  <p>returns <strong>true</strong>
  and</p>
  
  <pre><code>Object.is_a? Class
  </code></pre>
  
  <p><strong>too</strong>.</p>
  
  <p>wait, i am not done yet</p>
  
  <pre><code> Object.instance_of? Class
   Class.instance_of? Class
  </code></pre>
  
  <p>Both are true</p>
  
  <pre><code> Object.instance_of? Object
   Class.instance_of? Object
  </code></pre>
  
  <p>Both are false. right, nothing can be instance of object.</p>
  
  <p>And </p>
  
  <pre><code> Class.kind_of? Class
   Object.kind_of? Class
  </code></pre>
  
  <p>both are true</p>
  
  <pre><code> Class.kind_of? Object
   Object.kind_of? Object
  </code></pre>
  
  <p>both are true</p>
  
  <p>So both are exactly same, then why do we have both these.?</p>
  
  <p>After some more digging, i wrote this simple method to return method list supported by both</p>
  
  <pre><code>irb(main):054:0&gt; def print_methods(obj)
  irb(main):055:1&gt;    obj.methods.each do |mm|
  irb(main):056:2*        puts mm
  irb(main):057:2&gt;    end
  irb(main):058:1&gt; end
  </code></pre>
  
  <p>Only method difference between print_methods(Object) and print_methods(Class) is</p>
  
  <pre><code>     Nesting
  </code></pre>
  
  <p>if Nesting means inheritance, Is Object similar to the sealed class??</p>
  
  <p>Can someone clarify me what is all this?</p>
  
  <p><strong>Update:</strong> To Edds comment</p>
  
  <p>Interestingly i see lot of differences in the method list in</p>
  
  <pre><code>c=Class.new
  print_methods(c)
  </code></pre>
  
  <p>&amp;</p>
  
  <pre><code>o=Object.new
  print_methods(o)
  </code></pre>
  
  <p>Now I understand Instance of a class is really an class instance (And this class instance is actually a Object) not an  object instance. And even this instance allow me to span another instances</p>
  
  <pre><code>  xx = c.new //works - c is an Object / and xx is a instance of an Object c
    yy = o.new //nope  - o is already a instance of an Object, so it cannot be instantiated again
  </code></pre>
  
  <p>So Finally, Object is really an instance of a Class. Because</p>
  
  <pre><code>  xx.is_a? Class 
  </code></pre>
  
  <p>is false, but</p>
  
  <pre><code>  xx.is_a? Object 
  </code></pre>
  
  <p>returns true </p>
  
  <p>Am i right, ??</p>