# ObjectSpace.\_id2ref is giving different type output on Ruby 1.9.3p392 and Ruby 2.0.0p0?

**URL:** <https://www.ruby-forum.com/t/objectspace-id2ref-is-giving-different-type-output-on-ruby-1-9-3p392-and-ruby-2-0-0p0/227478>\
**Category:** Ruby\
**Created:** [March 17, 2013, 9:41am UTC](https://www.ruby-forum.com/t/objectspace-id2ref-is-giving-different-type-output-on-ruby-1-9-3p392-and-ruby-2-0-0p0/227478 "2013-03-17T09:41:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![my-ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e95f7d/32.png) [@my-ruby](https://www.ruby-forum.com/u/my-ruby)\
**Post date:** [March 17, 2013, 9:41am UTC](https://www.ruby-forum.com/t/objectspace-id2ref-is-giving-different-type-output-on-ruby-1-9-3p392-and-ruby-2-0-0p0/227478/1 "2013-03-17T09:41:48Z")

</div>

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
#=> #<Class:#<Foo:0x2041830>>
>> 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 `<main>'
>> 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 `<main>'
>> Foo.new.singleton_class.object_id
#=> 17139816
>> ObjectSpace._id2ref(17139816)
#=> "c"
```

---

<div class="post-metadata">

**Author:** ![my-ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e95f7d/32.png) [@my-ruby](https://www.ruby-forum.com/u/my-ruby)\
**Post date:** [March 17, 2013, 9:47am UTC](https://www.ruby-forum.com/t/objectspace-id2ref-is-giving-different-type-output-on-ruby-1-9-3p392-and-ruby-2-0-0p0/227478/2 "2013-03-17T09:47:45Z")

</div>

already fixed in ruby-trunk

and before you ask, yeah the object\_id of nil is changed in ruby-trunk  
too
