#instance_methods on a singleton class

X

Xavier Noria

Given:

class C
def self.m; end
end
class D < C; end

the superclass of the singleton class of D is the singleton class of C. However

(class << D; self; end).instance_methods(false)

includes m, both in 1.8 and 1.9. Is that intentional or is it a bug?
 
X

Xavier Noria

Given:

=C2=A0 =C2=A0class C
=C2=A0 =C2=A0 =C2=A0def self.m; end
=C2=A0 =C2=A0end
=C2=A0 =C2=A0class D < C; end

the superclass of the singleton class of D is the singleton class of C.

Just a remark here. That's what Flanagan & Matz says, but the draft of
the spec says that the superclass of an eigenclass is implementation
defined, and that the singleton class of D has the singleton class of
C among its superclasses.

So the question still holds, either the spec is wrong, or there's a
bug I believe. Perhaps I should ask in -core.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top