On Wed, Aug 12, 2009 at 10:25 PM, Ruby on
Rails[email protected] wrote:
Thanks Fred ,
I am not getting that concept of ruby . We have nil.object_id is 4
,are they fix for every value, i am not sure for this .
No, not in general, and the real story is rather dependent on the
particular Ruby implementation.
If we are talking the MRI (or Matz’ Ruby Implementation) then there
are a few objects like nil, true, false… with fixed object_ids, also
FixedNum instances have an object_id which can be computed from their
In general though the object_id is typically related to the address of
the object in memory, so you can’t rely on any fixed mapping based on
value, in fact, the object_id which is the identity of the object has
to be independent of the state for a mutable object.