...
| Warning | ||||
|---|---|---|---|---|
| ||||
GString and String are two distinct classes, and hence use of GString objects as keys for Map objects or comparisons involving GString objects, can produce unexpected results when combined with String objects since a GString and a String won't have the same hashCode nor will they be equal. There is no automatic coercion between the two types for comparisons or map keys, so it's sometimes necessary to explicitly invoke toString() on GString objects. On the other hand GStrings can easily be made into Strings
Unexpected conversion to String can lead to problems when code is expecting a GString, as for methods in groovy.sql classes. That's a case were explicit types can be benefifialbeneficial:
|
...