The associative array.
The key.
The callable to apply on create.
The callable to apply on update.
1 auto aa = ["k1": 1]; 2 3 aa.update("k1", { 4 return -1; // create (won't be executed 5 }, (ref int v) { 6 return v + 1; // update 7 }); 8 assert(aa["k1"] == 2); 9 10 aa.update("k2", { 11 return 0; // create 12 }, (ref int v) { 13 return -1; // update (won't be executed) 14 }); 15 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