Ned Konz wrote: >> OTOH, Ruby *doesn't* allow to change an object's class, unlike Perl and >> Python. The exception to that is when a object has class=Foo and >> changes to class=(new singleton class inheriting from Foo). > > You know, I've been meaning to ask how to do this (change the class of an > object). Is there something akin to Smalltalk's "become:" in which two > objects swap identities? That's one way to do this, of course. > > Also, how can one change the superclass of an existing class in Ruby? My apologies if I missed an explanation earlier in this thread, but ... Can someone explain under what circumstances one would want to change the class of an object? An example of the idiom would be useful. By the way, by "two objects swap identities", I assume you don't mean something like ... a, b = b, a so can you explain the purpose of swapping the identities of the objects?