On Monday, 9 October 2023 at 22:49:11 UTC, Salih Dincer wrote:
Great masters generally warn to stay away from stringof. Please do not use it as much as possible. The following code snippet will be useful to you:

```d
alias CN = __traits(allMembers, CardinalNumbers);

static foreach(i; CN)
{
  mixin(create_fn!(i[1]));
}

enum create_fn(char num) = `
  auto function_`~ num ~`()
    => "Hello from function `~ num ~`!";
`;

enum CardinalNumbers
{
  n0, n1, n2, n3, n4, n5, n6, n7, n8, n9
}

void main()
{
  assert(function_9() == "Hello from function 9!");
}
```

SDB@79

Thank you so much! This will do the trick. Have a beautiful day!

Reply via email to