What is the use case for this weird switch mecanism
bearophile
bearophileHUGS at lycos.com
Tue Oct 30 14:40:24 PDT 2012
Era Scarecrow:
> Maybe variable declaration (as long as they are default(s))?
> Has a certain amount of sense, but makes more sense to do it
> outside the switch case...
Declaring variables there is dangerous:
import std.stdio;
struct Foo {
int x = 10;
}
void main() {
int bar;
switch(bar) {
Foo f;
case 10: break;
default: writeln(f); // prints garbage
}
}
Bye,
bearophile
More information about the Digitalmars-d
mailing list