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[]
Written by Baruch Sadogursky
Related protips
2 Responses
You can also do def array = varargsMethod( set as String[] )
over 1 year ago
·
@tim_yates the power of Groovy (and protips :D)
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Groovy
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#