Switch and break

RenatoL rexlen at gmail.com
Thu Jan 19 13:55:06 PST 2012


Just curious: why in D we are not obligated to use break in every
branch of a swicth structure? That is:
	switch (i)
	{
		case 1:
		writeln("You wrote 1");
		case 2:
		writeln("You wrote 2");
		case 3:
		writeln("You wrote 3");
		default:
		writeln("I said: 1 or 2 or 3!");
        }

is good in D, while, for example, similar code in C# is incorrect
and if you want to play with fall through you have to make some
trick. Again this behaviour of D seems a bit buggy, to me. Are
there design reasons?


More information about the Digitalmars-d-learn mailing list