I've noticed that objects have their IDs assigned in a counterintuitive fashion. The earlier an object is created, the greater its object ID. I would have thought they would have been assigned in ascending order, rather than the other way around.
For example:
obj1 = Object.new
obj2 = Object.new
obj3 = Object.new
p obj1.object_id # => 4806560
p obj2.object_id # => 4806540
p obj3.object_id # => 4806520
Why are they assigned in such a way and also why is there a step of 20, rather than 1 in code run by the Ruby interpreter, but a vastly greater difference between object IDs for code run by Ruby's irb?
object_id
is just an integer that uniquely identifies an object, any particular order that you think you're seeing is purely an implementation artifact. – Ankh