On Saturday, 27 January 2018 at 17:54:53 UTC, thedeemon wrote:
On Saturday, 27 January 2018 at 11:19:37 UTC, Arun Chandrasekaran wrote:
Simplified test case that still errors:

You got really close here. Here's a working version:

enum Operation {
    a,
    b
}

import std.traits, std.conv, std.stdio;

void main(string[] args) {
    auto op = Operation.a;
    foreach (_; 0 .. args.length) {
        final switch (op) {
            foreach(e; EnumMembers!Operation) {
            case e:
                mixin(e.to!string ~ "();");
                break;
            }
        }
    }
}

void a() { writeln("A!"); }
void b() { writeln("B!"); }

Thanks, that did the trick.

How to use break inside a static foreach? Changing the above foreach each to static gives the following error:

Error: must use labeled break within static foreach


  • parallelism Arun Chandrasekaran via Digitalmars-d-learn
    • Re: parallelism Arun Chandrasekaran via Digitalmars-d-learn
    • Re: parallelism Nicholas Wilson via Digitalmars-d-learn
      • Re: parallelism Arun Chandrasekaran via Digitalmars-d-learn
        • Re: parallelism Arun Chandrasekaran via Digitalmars-d-learn
          • Re: paralleli... thedeemon via Digitalmars-d-learn
            • Re: para... Arun Chandrasekaran via Digitalmars-d-learn
              • Re: ... thedeemon via Digitalmars-d-learn
                • ... Arun Chandrasekaran via Digitalmars-d-learn

Reply via email to