[Issue 14411] switch statement: docs/behavior differ
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Apr 5 06:32:39 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=14411
--- Comment #1 from Cody Casterline <cody.casterline+dlang at gmail.com> ---
Aw. You have to download the example to see it. To save some time:
$ cat switch.d
#!/usr/bin/env rdmd
import std.stdio;
void main()
{
foreach (i; 1..7)
{
fn(i);
}
}
void fn(int i)
{
writeln("fn(", i, ")");
switch(i)
{
case 1, 2:
writeln(" A");
// break; not required!?
case 3:
case 4:
writeln(" B");
// break; not required!?
case 5:
writeln(" C");
// break; not required!?
default:
writeln(" D");
}
}
[codyc at eteco-2:~/test/dlang 01:32:02]
$ ./switch.d
fn(1)
A
B
C
D
fn(2)
A
B
C
D
fn(3)
B
C
D
fn(4)
B
C
D
fn(5)
C
D
fn(6)
D
--
More information about the Digitalmars-d-bugs
mailing list