From: "Jesús Gabriel y Galán" Date: 2012-01-15T01:03:56+09:00 Subject: Re: Language deisng question and stinrgs and object id's On Sat, Jan 14, 2012 at 4:16 PM, Ralph Shnelvar wrote: > JGyG> On Sat, Jan 14, 2012 at 3:38 PM, Ralph Shnelvar wrote: >>>  a = "string" >>>  b = "string" >>> >>>  causes 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? I think that's exactly what is causing your misunderstanding. The variable a is not an object. It doesn't have an object_id. It's just a reference, a pointer to an object. The only object in a = "string", is the object created by Ruby when it evaluates the string literal. When you then say a.object_id, what you are doing is sending the message "object_id" to the object referenced by a. Jesus.