From: Paul Brannan Date: 2008-09-18T23:07:19+09:00 Subject: Re: Singleton class's original class On Thu, Sep 18, 2008 at 04:43:40AM +0900, ara.t.howard wrote: > it might not be a class... but will this work? It would, except that calling #singleton_class isn't the only way to get a singleton class. :( > unless sc.respond_to?(:parent) > parent_id = self.object_id #Module === self ? self : self.class > sc.instance_eval "def parent() ObjectSpace._id2ref(#{ parent_id }) > end" > end Does doing this allow a class to be garbage-collected but allow its singleton class to stick around? Probably better to use define_method with a block in this case. Paul