"Mauricio FernáÏdez" <batsman.geo / yahoo.com> schrieb im Newsbeitrag news:20040915112257.GA14360 / student.ei.uni-stuttgart.de... > On Wed, Sep 15, 2004 at 05:09:52PM +0900, Robert Klemme wrote: > > >> o = Object.new > > => #<Object:0x10184d40> > > >> class << o; class << self; def to_s ; "foo" end end end > > => nil > > >> class << o; class << self;to_s end end > > => "foo" > > >> class << o; class << self; class << self; end end end > > => nil > > >> class << o; class << self; to_s end end > > => "#<Class:foo>" > > It's using Module#to_s because the klass of the singleton class is > no longer itself... Module#to_s ends up calling > class << o; self.to_s end > which you defined before. Well yes, but the fact remains that there is a singleton we don't know of, do we? Probably I don't see clearly your point so I'd appreciate it if you'd elaborate it. > > Hm, well ok. But is there an equivalent without evil.rb, i.e. with > > "normal" Ruby code? I know that you can access all kinds of internals if > > you write an extension, but AFAIK you can't know whether there is a > > singleton class or not. > > (I assume your last sentence if missing "... without an extension".) You can safely assume this without altering the indended semantics of the sentence. :-) > The case above (singletons of singletons) is the only one I can think > of right now where you can always know if the singleton has been created > or not. see above. Kind regards robert