title: Why isn't the eigenclass equivalent to self.class, when it looks so similar?
body: <p>I've missed the memo somewhere, and I hope you'll explain this to me.</p>
  
  <p>Why is the eigenclass of an object different from <code>self.class</code>?</p>
  
  <pre><code>class Foo
    def initialize(symbol)
      eigenclass = class &lt;&lt; self
        self
      end
      eigenclass.class_eval do
        attr_accessor symbol
      end
    end
  end
  </code></pre>
  
  <p>My train of logic that equates the eigenclass with <code>class.self</code> is rather simple:</p>
  
  <p><code>class &lt;&lt; self</code> is a way of declaring class methods, rather than instance methods. It's a shortcut to <code>def Foo.bar</code>.</p>
  
  <p>So within the reference to the class object, returning <code>self</code> should be identical to <code>self.class</code>. This is because <code>class &lt;&lt; self</code> would set <code>self</code> to <code>Foo.class</code> for definition of class methods/attributes.</p>
  
  <p>Am I just confused? Or, is this a sneaky trick of Ruby meta-programming?</p>