groovy: how to pass varargs and closure in same time to a method?
问题 Given following groovy function: def foo(List<String> params, Closure c) {...} The method call would be: foo(['a', 'b', 'c']) { print "bar" } But I would like to get rid of brackets (List) in the function call. something like: foo('a', 'b') { print "bar" } I cannot change the list parameter to varargs because varargs can be only the last parameter in function (here the closure is the last one). Any suggestion? 回答1: Seeing that it's impossible to achieve exactly what you want (it's written in