title: What is a singleton class in Ruby?
body: <p>I m having trouble understanding the concept of <strong>eigenclass</strong> or <strong>singleton class</strong> in ruby. I read a lot that the eigenclass <strong>is a class's class</strong>. That doesn't make sense to me as for me a class's class is actually <code>Class</code> as all classes are actually instances of the class <code>Class</code>.</p>
  <p>Another thing I don't quite get is the following statement: a class method is actually an instance method of the class eigenclass. The eigenclass is accessible this way :</p>
  <pre><code>YourClass = Class.new
  class &lt;&lt; YourClass
    def class_method
    end
  end
  </code></pre>
  <p>But if the eigenclass is indeed the YourClass class (that is <code>Class</code>), shouldn't the preceding piece of code open the class <code>Class</code> and add to it the instance method <code>class_method</code> making it accessible to all of its future instances (that is any regular class defined in the future)?</p>
  <p>I actually kind of feel that the singleton class is not the same as <code>Class</code>. When you do :</p>
  <pre><code>class MyClass
  end
  
  MyClass.singleton_class
  </code></pre>
  <p>you get <code>#&lt;Class:MyClass&gt;</code> which is different from the output of <code>MyClass.class =&gt; Class</code></p>
  <p>What is that <code>#&lt;Class:MyClass&gt;</code> output ? This has nothing to do with namespace as otherwise there would be two: <code>Class::MyClass</code>...</p>
  <p>I'm Looking for a simple and unambiguous explanation of the eigenclass concept in order to clarify my ideas.</p>