Concat enum of strings into one string

Andrey saasecondbox at yandex.ru
Tue Aug 14 14:03:25 UTC 2018


On Tuesday, 14 August 2018 at 13:45:48 UTC, Mike Franklin wrote:
> 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

Hmm, and to do it automatically, not manually?


More information about the Digitalmars-d-learn mailing list