startsWith using an array of needles

bearophile bearophileHUGS at lycos.com
Tue Aug 20 10:32:57 PDT 2013


Jonathan M Davis:

> startsWith dosen't take an array of needles. It takes a 
> variadic list of them.

All the argument after the first of startsWith could be required 
to be of the same type, for this D offers:

void foo(T)(T[] items...) {}
void main() {
     foo(1);
     foo(1, 2);
     foo(1, 2, 3);
     foo([1]);
     foo([1, 2]);
     foo([1, 2, 3]);
}


Isn't it better to modify startsWith a little like this?

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list