Groovy动态语言 运行在JVM中的动态语言 可以方便的处理业务逻辑变化大的业务
源代码在线查看: arrayparammethodtest.groovy
import groovy.DummyInterface
class ArrayParamMethodTest extends GroovyTestCase implements DummyInterface {
void testMethodCall() {
def array = "a b c".split(' ')
assert array.size() == 3
methodWithArrayParam(array)
}
void methodWithArrayParam(String[] args) {
println("first item: ${args[0]}")
// lets turn it into a list
def list = args.toList()
assert list instanceof java.util.List
list[4] = "e"
assert list == ["a", "b", "c", null, "e"]
println("Created list ${list}")
}
}