Superclass of eigenclass in 1.8.6

Discussion in 'Ruby' started by Paolo Nusco Perrotta, Apr 16, 2007.

  1. Test script:

    class Object
    # good old eigenclass accessor
    def eigenclass; class << self; self; end; end
    end

    class A; end
    class B < A; end
    b = B.new

    p "super of eigen of b: #{b.eigenclass.superclass}"
    p "super of eigen of B: #{B.eigenclass.superclass}"
    p "super of eigen of A: #{A.eigenclass.superclass}"

    Ruby 1.8.2 and Ruby 1.9 give the same result:

    MacNusco:/usr/bin nusco$ ruby -v /strange.rb
    ruby 1.8.2 (2004-12-25) [universal-darwin8.0]
    "super of eigen of b: B"
    "super of eigen of B: #<Class:A>"
    "super of eigen of A: #<Class:Object>"

    This is what I expected, and consistent with the way method lookup
    works for singleton methods in both objects and classes. On the other
    hand, Ruby 1.8.5 and 1.8.6 surprised me:

    MacNusco:/ nusco$ ruby -v /strange.rb
    ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.9.1]
    "super of eigen of b: #<Class:B>"
    "super of eigen of B: #<Class:Class>"
    "super of eigen of A: #<Class:Class>"

    What the heck?


    Paolo Perrotta
    Bologna, Italy
    Paolo Nusco Perrotta, Apr 16, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Evan Klitzke
    Replies:
    0
    Views:
    345
    Evan Klitzke
    Aug 2, 2007
  2. bart van deenen
    Replies:
    6
    Views:
    731
    bart van deenen
    Mar 3, 2009
  3. Trans
    Replies:
    19
    Views:
    179
    Trans
    Mar 15, 2006
  4. Matt Todd

    Defining Eigenclass

    Matt Todd, Aug 11, 2006, in forum: Ruby
    Replies:
    20
    Views:
    332
    Logan Capaldo
    Aug 13, 2006
  5. Danny O cuiv

    Superclass of eigenclass

    Danny O cuiv, May 7, 2009, in forum: Ruby
    Replies:
    29
    Views:
    418
    Jörg W Mittag
    May 20, 2009
Loading...

Share This Page