According to the Groovy docs, the == is just a "clever" equals() as it also takes care of avoiding NullPointerException:
Java’s
==is actually Groovy’sis()method, and Groovy’s==is a cleverequals()![...]
But to do the usual
equals()comparison, you should prefer Groovy’s==, as it also takes care of avoidingNullPointerException, independently of whether the left or right isnullor not.
So, the == and equals() should return the same value if the objects are not null. However, I'm getting unexpected results on executing the following script:
println "${'test'}" == 'test'
println "${'test'}".equals('test')
The output that I'm getting is:
true
false
Is this a known bug related to GStringImpl or something that I'm missing?