Associative array dup property?

bearophile bearophileHUGS at lycos.com
Wed Jun 16 10:12:42 PDT 2010


Adrian Matoga:
> So... is it a bug or is this feature missing intentionally?

I have asked for a .dup for AAs something like three years ago, and probably other people have asked for it years before. I think it will be added, but I presume nobody has implemented it yet.


> What would you recommend for concise, fast and safe surrogate?

This is a possible version (untested):

TV[TK] dup(TK, TV)(TV[TK] aa) {
        TV[TK] result;
        foreach (k, v; aa)
            result[k] = v;
        return result;
}

Bye,
bearophile


More information about the Digitalmars-d mailing list