30.09.2017 05:35, sarn пишет:

For anyone who's wondering, it works because switch is just a computed goto. The code's equivalent to this:

import std.stdio;

void main()
{
     int i = 0;

     // switch(i)
     if (i == 7)
     {
         goto case_7;
     }
     else
     {
         goto case_default;
     }

     // for loop initialiser
     i = 8;
     // for loop test
     while (i < 10)
     {
case_7:
         writeln(i);
         return;
case_default:
         // for loop update
         ++i;
     }
}

Thanks for clarification!

Reply via email to