为什么ObjectSpace._id2ref
在 Ruby 1.9 和 Ruby 2.0 上给出不同的输出?
红宝石 1.9.3p392 i386-mingw32
class Foo ; end
Foo.object_id #=> 17569464
ObjectSpace._id2ref(17569464) #=> Foo
Foo.new.singleton_class.object_id #=> 17075124
ObjectSpace._id2ref(17075124) #=> "\x00"
红宝石 2.0.0p0 i386-mingw32
class Foo ; end
Foo.object_id #=> 17197176
ObjectSpace._id2ref(17197176) #=> Foo
Foo.new.singleton_class.object_id #=> 19181436
ObjectSpace._id2ref(19181436) #=> RangeError: 0x124af7c is recycled object
Foo.new.singleton_class.object_id #=> 17454324
ObjectSpace._id2ref(17454324) #=> RangeError: 0x10a54f4 is not id value
Foo.new.singleton_class.object_id #=> 17139816
ObjectSpace._id2ref(17139816) #=> "c"