To what extent the source object should overwrite set (non-init) values in the receiving object.
Associative array to meld (source).
Reference to the associative array to meld (target).
int[string] aa1 = [ "abc" : 42, "def" : -1 ]; int[string] aa2 = [ "ghi" : 10, "jkl" : 7 ]; arr1.meldInto(aa2); assert("abc" in aa2); assert("def" in aa2); assert("ghi" in aa2); assert("jkl" in aa2);
import std.conv : to; { bool[string] aa1; bool[string] aa2; aa1["a"] = true; aa1["b"] = false; aa2["c"] = true; assert("a" in aa1); assert("b" in aa1); assert("c" in aa2); aa1.meldInto!(MeldingStrategy.overwriting)(aa2); assert("a" in aa2); assert("b" in aa2); assert("c" in aa2); } { string[string] aa1; string[string] aa2; aa1["a"] = "a"; aa1["b"] = "b"; aa2["c"] = "c"; aa1.meldInto!(MeldingStrategy.conservative)(aa2); assert("a" in aa2); assert("b" in aa2); assert("c" in aa2); aa1["a"] = "A"; aa1.meldInto!(MeldingStrategy.aggressive)(aa2); assert(aa2["a"] == "A"); }
Takes two associative arrays and melds them together, making a union of the two.
This is largely the same as the array-version meldInto but doesn't need the extensive template constraints it employs, so it might as well be kept separate.