From: Love U Ruby Date: 2013-03-17T17:41:53+09:00 Subject: ObjectSpace._id2ref is giving different type output on Ruby 1.9.3p392 and Ruby 2.0.0p0 ? Couldn't understand - Why does `ObjectSpace._id2ref` giving different type of output on `Ruby 1.9.3p392` and `Ruby 2.0p0` ? ***Ruby 1.9.3p392*** C:\>ruby -v ruby 1.9.3p392 (2013-02-22) [i386-mingw32] C:\>irb --simple-prompt >> class Foo ; end #=> nil >> Foo.object_id #=> 17569464 >> ObjectSpace._id2ref(17569464) #=> Foo >> Foo.new.singleton_class #=> #> >> Foo.new.singleton_class.object_id #=> 17075124 >> ObjectSpace._id2ref(17075124) #=> "\x00" ***Ruby 2.0.0p0*** C:\>ruby -v ruby 2.0.0p0 (2013-02-24) [i386-mingw32] C:\>irb --simple-prompt DL is deprecated, please use Fiddle >> class Foo ; end #=> nil >> Foo.object_id #=> 17197176 >> ObjectSpace._id2ref(17197176) #=> Foo >> Foo.new.singleton_class.object_id #=> 19181436 >> ObjectSpace._id2ref(19181436) #RangeError: 0x124af7c is recycled object # from (irb):5:in `_id2ref' # from (irb):5 # from C:/Ruby200/bin/irb:12:in `
' >> Foo.new.singleton_class.object_id #=> 17454324 >> ObjectSpace._id2ref(17454324) #RangeError: 0x10a54f4 is not id value # from (irb):7:in `_id2ref' # from (irb):7 # from C:/Ruby200/bin/irb:12:in `
' >> Foo.new.singleton_class.object_id #=> 17139816 >> ObjectSpace._id2ref(17139816) #=> "c" -- Posted via http://www.ruby-forum.com/.