switch ( Expression ) ScopeStatement
bearophile
bearophileHUGS at lycos.com
Mon Jul 6 19:10:20 PDT 2009
Derek Parnell:
> is valid syntax! Why is that?
To allow train-wrecks like this one:
version(Tango) import tango.stdc.stdio;
void main(char[][] args) {
if (args.length > 1)
switch (args[1]) {
int x = 1; // This initialization to 1 doesn't happen,
// it's the same as int x = void;
case "1": printf("1! x=%d\n", x); break;
case "2": printf("2! x=%d\n", x); break;
}
}
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list