Jesų¸,

Saturday, January 14, 2012, 9:03:56 AM, you wrote:

JGyG> On Sat, Jan 14, 2012 at 4:16 PM, Ralph Shnelvar <ralphs / dos32.com> wrote:
>> JGyG> On Sat, Jan 14, 2012 at 3:38 PM, Ralph Shnelvar <ralphs / dos32.com> wrote:
>>>>  = "string"
>>>>  = "string"
>>>>
>>>> auses three objects with different object id's to be created.
>>
>> JGyG> It actually causes just two objects to be created.
>>
>> Or does it create 4 objects?
>>
>> In other words, is the first "string" object created and then cloned?
>>
>> Is there a way to see the object id's of the variable "a" and "string" in the first statement?

JGyG> I think that's exactly what is causing your misunderstanding. The
JGyG> variable a is not an object. It doesn't have an object_id. It's just a
JGyG> reference, a pointer to an object. The only object in a = "string", is
JGyG> the object created by Ruby when it evaluates the string literal. When
JGyG> you then say a.object_id, what you are doing is sending the message
JGyG> "object_id" to the object referenced by a.

JGyG> Jesus.

Thank you.  It is a good explanation.

Is there a way to see the object id's of the variable "a" and "string" in the first statement?