Well, actually after checking GString.equals()
method implementation it's not a mystery why it works as it works.
public boolean equals(Object that) {
if (that instanceof GString) {
return equals((GString) that);
}
return false;
}
The question remains, is it desired behaviour, shouldn't it return true
by design in this case?
With the false
in place it's easy to run into quite unexpected behaviour like:
"${'1'}" in ['1', '2', '3']
...is going to return false.
Is the current behaviour a result of equals and hashCode consistency contract or could it be improved to return more accurate results?