e3qhtg
Last Updated: February 25, 2016
·
2.473K
· jbaruch
3d73332968c0bf62e1ece7299deb8b37

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[]
Say Thanks
Respond

2 Responses
Add your response

3771
De6eafe28472ceb9522fd3f609afed53

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

over 1 year ago ·
3772
3d73332968c0bf62e1ece7299deb8b37

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

over 1 year ago ·