How to mixin finction name?
Andrey
saasecondbox at yandex.ru
Sun Apr 14 12:00:38 UTC 2019
On Sunday, 14 April 2019 at 11:44:16 UTC, Boris Carvajal wrote:
> 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);
> }
I want to mixin only name - not the full function code.
More information about the Digitalmars-d-learn
mailing list