On Fri, Apr 21, 2017 at 07:17:32PM +0000, Adam D. Ruppe via Digitalmars-d-learn wrote: > On Friday, 21 April 2017 at 19:09:25 UTC, Johan Fjeldtvedt wrote: > > void foo(string s) { > > enum es = tuple("a", "b", "c"); > > switch (s) { > > foreach (e; es) { > > case e: > > writeln("matched ", e); > > break; > > } > > Let me remove some surrounding stuff and ask you what happens: > > foreach (e; es) { > if(s == c) { > writeln("matched ", e); > break; > } > } > > > What does that break do? > > > Then realize that it does exactly the same thing when it is inside a > switch... it always breaks the innermost thing, which happens to be > this loop. (note that cases are not `breaked`, the switch is.)
Yeah, you want to label your switch statement, say `mySwitch:`, so that you can do a `break mySwitch;` T -- Knowledge is that area of ignorance that we arrange and classify. -- Ambrose Bierce