No fall-through for switch (WAS: Re: [Submission] D Slices)

Andrej Mitrovic andrej.mitrovich at gmail.com
Sun Jun 12 20:28:56 PDT 2011


Hey I've just realized something (well, it was in the docs, doh!), we
can use already use "switch case;" to fallthrough to the next label
without explicitly using goto:

void main()
{
    int x = 2;
    switch (x)
    {
        case 2:
            goto case;  // goto case 3;
            break;

        case 3:
            writeln("case 3");

        default:
    }
}

So the pain of updating the code is minimal with the new changes in place.


More information about the Digitalmars-d mailing list