From: John W Higgins Date: 2013-03-07T02:50:12+09:00 Subject: Re: Why there are always fixed object_id s for Boolean objects? --047d7b3438ae29883704d7451d99 Content-Type: text/plain; charset=ISO-8859-1 As usual http://ruby-doc.org/core-2.0/TrueClass.html John On Wed, Mar 6, 2013 at 9:37 AM, Kumar R. wrote: > 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/. > > --047d7b3438ae29883704d7451d99 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable As usual

htt= p://ruby-doc.org/core-2.0/TrueClass.html

John

On Wed, Mar 6, 2013 at 9:37 AM, Kumar R. <lists@ruby-forum.com> wrote:
If you find the below test,you would see tha= t, `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
=3D> 2
>> false.object_id
=3D> 0
>> nil.object_id
=3D> 4
>> 'a'.object_id
=3D> 17515344
>> nil.object_id
=3D> 4
>> 'a'.object_id
=3D> 18433428
>> false.object_id
=3D> 0
>> 'a'.object_id
=3D> 18454176
>> true.object_id
=3D> 2
>>

--
Posted via http://= www.ruby-forum.com/.


--047d7b3438ae29883704d7451d99--