Message-ID: <121511865.97405.1398028671092.JavaMail.email@example.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_97404_1397206830.1398028671091" ------=_Part_97404_1397206830.1398028671091 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
This is described here.=20
Basically in Java =3D=3D with primitive types means use equality. For ob= ject types =3D=3D means test identity.=20
We found when working with Groovy that if we kept those semantics and fo= lks used dynamic typing as follows=20 =20
They would get surprising results, as they often mean equality based on = value, such as in the above, rather than identity. Indeed folks rarely ever= use identity comparisions.=20
So to avoid many common gotchas and confusions, we've made =3D=3D mean e= quals, the meaning most developers use, and we use this for both primitive = types and for object types and across both static and dynamic typing to sim= plify things.=20
Currently if you really want to compare identities of the objects, use t= he method is(), which is provided by every object.=20 =20
The above condition is never true, since the Integer object in x (= which is the result of the computation above) is not identical to the Integ= er object with value 4 that has been created for the comparison.