相关疑难解决方法(0)

Groovy多行字符串出了什么问题?

Groovy脚本引发错误:

def a = "test"
  + "test"
  + "test"
Run Code Online (Sandbox Code Playgroud)

错误:

No signature of method: java.lang.String.positive() is 
applicable for argument types: () values: []
Run Code Online (Sandbox Code Playgroud)

虽然这个脚本工作正常:

def a = new String(
  "test"
  + "test"
  + "test"
)
Run Code Online (Sandbox Code Playgroud)

为什么?

string groovy multiline

93
推荐指数
3
解决办法
7万
查看次数

标签 统计

groovy ×1

multiline ×1

string ×1