From: Konrad Meyer Date: 2007-09-28T03:07:53+09:00 Subject: Re: Ruby's a = b vs PHP5's $obj1 =& $obj2 --nextPart1554348.S3NVju4d6m Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Quoth SpringFlowers AutumnMoon: > Just want to confirm Ruby's >=20 > a =3D b >=20 > is the same as PHP5's >=20 > $obj1 =3D $obj2 >=20 > in other words, the reference is copied. >=20 > While >=20 > $obj1 =3D& $obj2 >=20 > or >=20 > $obj1 =3D &$obj2 >=20 > in both PHP4 and PHP5 isn't the same as Ruby's a =3D b >=20 > $obj1 and $obj2 just become synonyms... >=20 > and after >=20 > $obj1 =3D new Foo("foo1"); > $obj2 =3D& $obj1 > $obj2 =3D new Foo("bar1"); >=20 > $obj1 and $obj2 have the same content, as they are just synonyms. (not a > clone, not same reference, but just synonyms). The "foo1" object is > garbage-collected since no one is referencing it. >=20 > this is giving me an initial headache... until maybe after i get used to > it. PHP's $var1 =3D& $var2 seems to be setting a reference to a reference. I th= ink=20 ruby is more like PHP's $var1 =3D $var2, though I could be wrong. HTH, =2D-=20 Konrad Meyer http://konrad.sobertillnoon.com/ --nextPart1554348.S3NVju4d6m Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQBG+/FgCHB0oCiR2cwRAq+TAKCfCgO6r9RCW8mhXnMuHq+hkq2/wgCbB0mv 1uIfnf/jIJ0DABJLzfQ1SMc= =R+n0 -----END PGP SIGNATURE----- --nextPart1554348.S3NVju4d6m--