title: Accessing a singleton class
body: <p>Adding the following code to an object is supposed to allow me to retrieve the singleton class of any object. </p>
  
  <pre><code>class Object
      def singleton_class
          class &lt;&lt; self; self; end
      end
  end
  </code></pre>
  
  <p>I had a Powerball class, which I instantiated this way</p>
  
  <pre><code>puts Powerball.new.singleton_class
  puts Powerball.new.singleton_class
  puts Powerball.singleton_class
  puts Powerball.singleton_class
  </code></pre>
  
  <p>It gave me this output</p>
  
  <pre><code>#&lt;Class:#&lt;Powerball:0x007fd333040548&gt;&gt;
  #&lt;Class:#&lt;Powerball:0x007fd333040408&gt;&gt;
  #&lt;Class:Powerball&gt;
  #&lt;Class:Powerball&gt;
  </code></pre>
  
  <p>So, the two instances of the powerball class have unique ids, while calling singleton_class directly on the class doesn't yield an object id.</p>
  
  <p>Questions</p>
  
  <ol>
  <li><p>Are the ids unique because each <em>instance</em> has a singleton class?</p></li>
  <li><p>I understand that <code>self</code> within a class just returns the Class i.e. Class:Powerball, but since a class is an object, shouldn't it also have an id? Is there a way to access that id?</p></li>
  </ol>