On Tuesday, 14 August 2018 at 13:42:04 UTC, Andrey wrote:
Hello,
I have a enum:
enum Type : string
{
One = "Q1",
Two = "W2",
Three = "R3"
}
I want to concat it in compile-time:
enum result = doConcat!Type();
And get this result:
writeln(result); // output: "Q1 W2 R3"
Delimiter here is space symbol.
How do do it?
I think you just need to use the concatenation operator `~`.
enum Type : string
{
One = "Q1",
Two = "W2",
Three = "R3"
}
enum concatenation = Type.One ~ " " ~ Type.Two ~ " " ~ Type.Three;
void main()
{
import std.stdio: writeln;
writeln(concatenation);
}
Mike