【发布时间】:2011-07-02 01:49:33
【问题描述】:
Groovy 脚本引发错误:
def a = "test"
+ "test"
+ "test"
错误:
No signature of method: java.lang.String.positive() is
applicable for argument types: () values: []
虽然此脚本运行良好:
def a = new String(
"test"
+ "test"
+ "test"
)
为什么?
【问题讨论】:
-
如果它对其他人有帮助,您可以使用类似
def a = b + + "/" + c的代码得到同样的错误。在这种情况下,两个 + 符号显然是问题所在。