The associative array.
The key.
The callable to apply on create.
The callable to apply on update.
auto aa = ["k1": 1]; aa.update("k1", { return -1; // create (won't be executed) }, (ref int v) { v += 1; // update }); assert(aa["k1"] == 2); aa.update("k2", { return 0; // create }, (ref int v) { v = -1; // update (won't be executed) }); assert(aa["k2"] == 0);
Looks up key; if it exists applies the update callable else evaluates the create callable and adds it to the associative array