From: EbFFA Date: 2009-08-25T15:06:39+09:00 Subject: doubling numbers with Object#object_id I was playing with Ruby and wrote an interesting method: def double n n.object_id - 1 end irb> double 5 => 10 irb> double 1 => 2 irb> double 0 => 0 irb> double -101 => -202 irb> double 100000001 => 200000002 irb> double 10000000000 # into Bignum territory now => -606548539 Anyone know why this works? Why Ruby was implemented this way? I tried creating an object_id collision based on this doubling rule, but it seems that all Fixnum object_id`s are odd, and all other object_id`s are even (in fact they all seem to end in 8). Clever.