The spec gives this signature for .update on associative arrays:
> .update(Key key, Value delegate() create, Value delegate(Value) update)
https://dlang.org/spec/hash-map.html#properties
But the actual implementation in druntime also allows returning void:
```
void main() {
int[int] aa;
aa.update(3, () => 3, (int x) {});
}
```
The idea being that the delegate can take the existing value by `ref` and update that way as well. This is how the update function is described:
> The update function provides a means to construct a new value via the
> create delegate or update an existing value via the update delegate.
> Looks up key; if it exists applies the update delegate else evaluates
> the create delegate and adds it to the associative array
This doesn't specify how the update delegate is actually applied, and whether you need to modify with ref, return a new value, or both.
Comment #1 by dlang-bot — 2022-08-01T12:46:57Z
dlang/dlang.org pull request #3360 "Fix Issue 22237 - AA.update is underspecified" was merged into master:
- 2779bf1a92180fc741b203982b799c864bdfde3c by Nick Treleaven:
Fix Issue 22237 - AA.update is underspecified
Make example runnable.
Update example to match part of
https://github.com/dlang/dlang.org/pull/3358.
Add link to object.update.
https://github.com/dlang/dlang.org/pull/3360