break switch?

Timon Gehr timon.gehr at gmx.ch
Sun Jun 9 16:36:25 PDT 2013


On 06/10/2013 01:23 AM, bearophile wrote:
> ...
>
> Do you like? :-)
>
> Bye,
> bearophile


Are you aware that the following works?

void main(){
     import std.stdio;
     enum Foo{foo1,foo2}
     int[5] data;
     Foo f;
     Lswitch:switch(f){
     case Foo.foo1:
         foreach (x;data)
             if(x==10)
                 break Lswitch;
         writeln("10 not found.");
         data[0] = 10; // Put the missing 10.
         break;

     default:
         break;
     }
}




More information about the Digitalmars-d mailing list