TLDR MRI gets the value of the number directly from value of the C pointer and saves the lookup. It's a 1 in the lowest bit and the integer value in the others. That's why 0.object_id == 1, 1.object_id == 3, etc
Obviously that's implementation dependent but I guess no Ruby implementation is going us to redefine integers if MRI does not.
More evidence:
So Integer is not like other classes and the actual reason for that http://archive.oreilly.com/pub/post/the_ruby_value_1.htmlTLDR MRI gets the value of the number directly from value of the C pointer and saves the lookup. It's a 1 in the lowest bit and the integer value in the others. That's why 0.object_id == 1, 1.object_id == 3, etc
Obviously that's implementation dependent but I guess no Ruby implementation is going us to redefine integers if MRI does not.