Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Changed description to contain the method is() instead of ===


Code Block
def x = 2 * 2
if (x == 4) {


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.

So to avoid many common gotchas and confusions, we've made == mean equals, 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 simplify things.

Currently if you really wanna want to compare identities of the objects, use ===the method is(), which is provided by every object.

No Format

if ( {
... // never true

 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 Integer object with value 4 that has been created for the comparison.