e3qhtg
Last Updated: February 25, 2016
·
3.76K
· jbaruch

Groovy - pass Set as varargs

def varargsMethod(String ... args){
    args
}

Set set = ['a','b', 'c']

def array = varargsMethod(* (set as List))
assert (array as List).containsAll(set)
assert array instanceof String[]

2 Responses
Add your response

3771

You can also do def array = varargsMethod( set as String[] )

over 1 year ago ·
3772

@tim_yates the power of Groovy (and protips :D)

over 1 year ago ·