7stud2
(7stud --)
1
If you find the below test,you would see that, `object_id`s are always
same for the three objects - `true`,`false` and `nil`.
Why for these objects `object_id` s are not allocated in run time?
true.object_id
=> 2
false.object_id
=> 0
nil.object_id
=> 4
'a'.object_id
=> 17515344
nil.object_id
=> 4
'a'.object_id
=> 18433428
false.object_id
=> 0
'a'.object_id
=> 18454176
true.object_id
=> 2
···
--
Posted via http://www.ruby-forum.com/\.
7stud2
(7stud --)
2
Because they refers to constants created when the VM arise, always.
nil.==(NIL)
true.==(TRUE)
false.==(FALSE)
Perhaps could be a better explanation.
···
--
Posted via http://www.ruby-forum.com/.
7stud2
(7stud --)
4
object_ids are also the same for Fixnum objects
its a feature not a bug
PS: but they can differ between different ruby versions
(in 2.0 little floats are also have fixed ids)
···
--
Posted via http://www.ruby-forum.com/.