Merging two hashes

Andrej Mitrovic andrej.mitrovich at gmail.com
Fri Jan 20 09:46:40 PST 2012


Is there a way to merge the keys from one hash to another (overwriting
any duplicates) without using a foreach loop? E.g.:

void main()
{
    int[int] a, b;
    a[0] = 0;
    b[1] = 1;

    b += a;  // ?
}

It's not too hard to write this of course:
    foreach (key, val; a)
        b[key] = val;

But I'm wondering if an enhancement request is in order, maybe an
operator overload, or maybe a special merge function.


More information about the Digitalmars-d-learn mailing list