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. This is valid ... module test; import tango.io.Stdout; void main(char[][] args) { if (args.length > 1) switch (args[1]) case "1": Stdout("1"); // break; //uncomment and error } Ok, why on earth would a one-case switch be useful? And that still doesn't help me understand why allowing other statement types in that position is a good idea. -- Derek Parnell Melbourne, Australia skype: derek.j.parnell