Is it possible to change the class of a Ruby object once it has been instantiated, something like:
class A
end
class B
end
a = A.new
a.class = B
No, this is not possible from within ruby.
It is theoretically possible from within a C extension by changing the klass
pointer of the given object, but it should be noted that this will be completely implementation-specific, will not work for immediate types (i.e. you definitely can't change the class of e.g. a fixnum), and might blow up in various ways.