Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Won't Fix
-
None
-
None
-
None
Description
This test case fails with the exception below:
void testInvokeToStringOnPlus()
{ def obj = new ToString(val:"some string") assert obj + " + another string" == "some string + another string" }class ToString {
@Property val
public String toString()
}
testInvokeToStringOnPlus(StringTest)groovy.lang.MissingMethodException: No signature of method ToString.plus() is applicable for argument types: (java.lang.String) values:
{" + another string"}If plus(String) is not overriden by the class being concatenated with the + operator, it should call toString() instead.
to convert the Object to string, if the Object is on the left side might look reasonable, but it won't work as suspected if a subclass overwrites plus for String. having to write ""obj"aString" is not that bad. If you don't want to, use GStrings: "$obj aString"