this for method chaining.
Preconditions: Both this and other must be Type.OBJECT (or this is NULL, which gets promoted). Asserts if either is a non-object, non-NULL type.
var merge(const var other, bool deepMerge = false) ref return @safeMerge another object into this one.
This method combines the key-value pairs from other into this var. It only works when both this and other are objects (Type.OBJECT).
Conflict resolution:
other overwrite existing values in this (last wins).deepMerge is true, nested objects are recursively merged instead of replaced.other | The object to merge into this one. |
deepMerge | If true, recursively merge nested objects. Default is false. |
this for method chaining.
Preconditions: Both this and other must be Type.OBJECT (or this is NULL, which gets promoted). Asserts if either is a non-object, non-NULL type.
var base;
base["a"] = 1;
base["b"] = 2;
var overlay;
overlay["b"] = 20;
overlay["c"] = 30;
base.merge(overlay);
assert(base["a"].as!int == 1);
assert(base["b"].as!int == 20); // overwritten
assert(base["c"].as!int == 30); // added