On Friday, 21 April 2017 at 19:17:32 UTC, Adam D. Ruppe 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.)

*facepalm* Of course! Thanks.

Reply via email to