Groovy parameter "String..." -


i'm in midst of implementing unit tests web application , i've come across piece of code (and others) have parameter "string..." i'm not sure "..." means, if @ all, can't find explanation anywhere.

public static list<user> getusersforgroups(string... dns) {     set<string> members = getmembers(dns)     return members.collect{ getuser(it) }.findall{ }.sort{ user u -> "$u.lastname  $u.firstname"} } 

this java feature called varargs, groovy supports it. lets method accept multiple parameters without making caller package them data structure first. arguments bundled array before being passed method:

groovy:000> def foo(string... stuff) { groovy:001>   println(stuff.class) groovy:002>   (s in stuff) { groovy:003>     println(s) groovy:004>   }} ===> true groovy:000> foo('a','b','c','d') class [ljava.lang.string; b c d ===> null groovy:000> foo('q') class [ljava.lang.string; q ===> null 

class [ljava.lang.string; means it's array (as opposed java.util.arraylist).


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -