From: Robert Klemme Date: 2004-05-18T18:13:49+09:00 Subject: Re: Why do #dup and #clone behave differently with respect to instance methods "ts" schrieb im Newsbeitrag news:200405180806.i4I86o026601@moulon.inra.fr... > >>>>> "R" == Robert Klemme writes: > > R> Sounds reasonable. Still *something* strikes me as odd: #class still > R> returns the original class. Why doesn't it return the singleton class? > > #class always return the class of the object. > > R> One *could* expect something different here. Any comments? > > class A > end > > a = A.new > b = A.new > > class << a > def a > end > end > > p a.class == b.class > > > Now do you really expect 'false' ? Well, I don't since I know it's done otherwise in Ruby. But, one *could* reasonably. Still (A === a) == true and (A === b) == true. I just wanted to point out that although there is this anonymous class of the instance it's not accessible in any way I know of (other than iterating through ObjectSpace maybe). An alternative would be that "class << a" could return this singleton class... Regards robert