In Ruby, why does inspect() print out some kind of object id which is different from what object_id(
Posted
by Jian Lin
on Stack Overflow
See other posts from Stack Overflow
or by Jian Lin
Published on 2010-05-12T12:10:21Z
Indexed on
2010/05/12
12:14 UTC
Read the original article
Hit count: 153
When the p
function is used to print out an object, it may give an ID, and it is different from what object_id()
gives. What is the reason for the different numbers?
>> a = Point.new
=> #<Point:0x4684abc>
>> a.object_id
=> 36971870
>> a.__id__
=> 36971870
>> "%X" % a.object_id
=> "234255E"
© Stack Overflow or respective owner