On Wednesday, 6 July 2016 at 19:50:11 UTC, pineapple wrote:
I'd like to do something like this but it doesn't seem to be legal -

    void test(int[] ints...) if(ints.length){
        // stuff
    }

Not being able to specify this interferes with how I'd like to define my method overloads. What's the best way to achieve what I'm looking for?

Is this close enough?

void test(int first, int[] rest...) {
    auto ints = only(first).chain(rest);
    // stuff
}
void main() {
    //test(); // fails to compile
    test(1);
    test(1,2,3);
}

Reply via email to