#instance_methods on a singleton class

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?

On Fri, Mar 19, 2010 at 12:08 PM, Xavier N. [email protected] wrote:

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.

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs