switch ( Expression ) ScopeStatement

Tim Matthews tim.matthews7 at gmail.com
Mon Jul 6 21:05:26 PDT 2009


Derek Parnell wrote:
> On Tue, 07 Jul 2009 14:57:39 +1200, Tim Matthews wrote:
> 
>> Switch is really a neat form of comparison and gotos but with actual 
>> labels replaced with a case statement. A block statement is usually used 
>> to have more than one case statement valid. This is valid code but 
>> uncomment the next line and it becomes invalid:
>>
>> module test;
>>
>> import tango.io.Stdout;
>>
>> void main(char[][] args)
>> {
>>    if (args.length > 1)
>>      switch (args[1])
>>        case "1": Stdout("1"); break;
>>        //case "2": Stdout("2"); break; //uncomment and error
>>
>> }
> 
> Actually that is not valid code. The first "break;" breaks the program.
> 

It shouldn't have accepted it so it's here now. 
http://d.puremagic.com/issues/show_bug.cgi?id=3144


More information about the Digitalmars-d-learn mailing list