Log in / create account | Login with OpenID
DocForge
Programmer's Wiki

Variadic

From DocForge

A variadic is a function which can accept a variable number of arguments.

Digital Mars D (from tango.io.Path)

static char[] join (char[][] paths...)
{
    char[] result;
 
    foreach (path; paths)
        result ~= padded (path);
 
    return result.length ? result [0 .. $-1] : "";
}

Java (1.5 and higher) (not from anywhere, I made it up off the top of my head)

String foo(String args...) {
    StringBuilder sb=new StringBuilder();
 
    foreach(String s: args) {
        sb.append(s);
    }
 
    return sb.toString();
}