From: Eero Saynatkari Date: 2005-12-22T07:40:08+09:00 Subject: Re: A interesting obervation about object_id method Devin Mullins wrote: > Hank Gong wrote: > >>#integer >> >> >>#You can see that: >># 1) for the same integer, the object_id is the same >> >> > That's because Fixnums are "immediate." So are Symbols. It's a > performance thing. It also means, for example, you can't define > singleton methods on a Fixnum. Notice, actually, that you can decode the > integer value *from* the object-id, and vice versa. Even without going to implementation details, the code is logical: each number is a constant instance of the Fixnum (or other) class: # Pseudo 1 = Fixnum.new("Number one") Then, logically, all variables referencing the number 1 are pointing to the same object. > > > Devin E -- Posted via http://www.ruby-forum.com/.