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:
>>> =A0a =3D "string"
>>> =A0b =3D "string"
>>>
>>> =A0causes 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 =3D "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.