From: Carlos Date: 2004-03-09T02:13:59+09:00 Subject: Re: proposal: class<, 2004-03-08 17.53 CET] > Here's a brute-force but perhaps useable implementation: > > class Class > def single_instance > ObjectSpace.each_object do |obj| > c = (class << obj; self; end) > return obj if c == self > end > end > end > > p (class << "hello"; self; end).single_instance # "hello" In fact, there seems to be an instance variable named "__attached__" in singleton classes, that is linked to the instance. It is not accessible from ruby (because it doesn't start with "@"); I guess this is a design decision (?).