Just because in 2.0
the garbage collector was defter.
# RangeError: 0x124af7c is recycled object
states for the object was already GC’ed.
UPD: We can approach the requested behaviour with Mutex
:
2.0.0 (main):0 > Mutex.new.synchronize {
2.0.0 (main):0 * class Foo ; end
2.0.0 (main):0 * id = Foo.new.singleton_class.object_id
2.0.0 (main):0 * puts id
2.0.0 (main):0 * puts ObjectSpace._id2ref(id)
2.0.0 (main):0 * }
# 23172260
# <Class:#<Foo:0x00000002c32970>>