How to use ".stringof" to get the value of a variable and not the name of the variable (identifier) itself?
Nick Treleaven
nick at geany.org
Fri Oct 13 10:11:33 UTC 2023
On Tuesday, 10 October 2023 at 11:45:25 UTC, Dennis wrote:
> ```D
> enum itoa(int i) = i.stringof;
>
> static foreach(i; 0 .. 10) {
> mixin(create_fn!(itoa!i));
> }
> ```
You can also do it using a string mixin:
mixin(create_fn!(mixin("`", i, "`")));
I think that's equivalent to `i.stringof` anyway.
More information about the Digitalmars-d-learn
mailing list