uniq and array of enum members (That are all strings)

bauss jj_1337 at live.dk
Wed Jan 16 15:57:49 UTC 2019


Is there a way to achieve the following:

import std.stdio;

import std.algorithm : uniq;
import std.array : array;

enum Foo : string
{
     a = "aa",
     b = "bb",
     c = "cc"
}

void main()
{
     auto a = [Foo.a, Foo.b, Foo.a, Foo.b, Foo.c];

     auto b = a.uniq;

     writeln(b);
     // Expected output: [a, b, c]
     // Outputs: [a, b, a, b, c]
}


More information about the Digitalmars-d-learn mailing list