为什么这个 groovy 代码
def versionString = '10.15.20'
int major
int minor
int patch
(major, minor, patch) = versionString.split(/\./).each { Integer.parseInt(it) }
println "$major.$minor.$patch"
抛出这个异常
Caught: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '10' with class 'java.lang.String' to class 'int'
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '10' with class 'java.lang.String' to class 'int'
而不是显示 10.15.20?
即为什么变量分配有 split() 的输出而不是闭包的输出?