From: Charles Oliver Nutter Date: 2011-03-05T16:14:01+09:00 Subject: Re: Ruby Hash Keys and Related Questions On Wed, Feb 23, 2011 at 2:25 AM, Robert Klemme wrote: > No, IRB shows the result of obj.inspect.  The default implementation > returns something which is related to #object_id which in turn is > derived from the address (I forgot the details): > > irb(main):010:0> o=Object.new > => # > irb(main):011:0> o.object_id.to_s 16 > => "3ffb962e" > irb(main):012:0> 0x7ff72c5c / 0x3ffb962e > => 2 > > Anyway, since you cannot access memory directly from Ruby it's > worthless to know the memory address.  And in other Ruby > implementations (e.g. JRuby) that memory address may even change. > Forget C (until you write your first Ruby extension). In JRuby, object IDs are allocated monotonically only as needed, so they have nothing to do with a given object's memory location. They will stay the same once requested, but they're little more than a number we attach to the object. Because we don't globally track them, they're not guaranteed to be unique forever. But they'll be unique for 63 bits worth of object IDs (64 bits / 2). - Charlie