>    def instance_of_singleton_class_2(sc)

not only is this method faster but it works in a situation where the 
ObjectSpace does not. Consider this rspec test pasted in from a personal 
introspection lib. It will work with this method but not with the 
ObjectSpace:

  def singleton
     class<<self;self;end
  end

  def singleton_ancestors
    result = []
    return result unless pointer = singleton_parent
    result << self
    begin
      result << pointer
    end while pointer = pointer.singleton_parent
    result
  end

    it "should get singletons back in the correct order" do
      parent = ""
      a = parent.singleton
      b = a.singleton
      c = b.singleton
      d = c.singleton
      e = d.singleton
      f = e.singleton
      f.singleton_ancestors.should == [ f, e, d, c, b, a, parent ]
    end

-- 
Posted via http://www.ruby-forum.com/.