How to mixin finction name?

Boris Carvajal boris2.9 at gmail.com
Sun Apr 14 11:44:16 UTC 2019


On Sunday, 14 April 2019 at 10:07:30 UTC, Andrey wrote:
> Create some function in loop and use it. But I don't know how 
> to mixin names?


import std.stdio;
void main()
{
      enum letters = ['A', 'B', 'C'];
      static foreach(ch; letters)
      {
          mixin("void print" ~ ch ~ "(uint i) { writeln('" ~ ch ~ 
"', \" - \", i); }");
      }

      printA(1);
      printB(2);
      printC(3);
}


More information about the Digitalmars-d-learn mailing list