Modifying an associative array argument not passed by ref
Anonymouse
zorael at gmail.com
Sat Mar 8 12:14:52 UTC 2025
On Saturday, 8 March 2025 at 12:02:41 UTC, Nick Treleaven wrote:
> `assert(0 in aa2)` actually fails too.
So it does! My bad. It makes more sense now.
> When an AA is null, it must be passed by ref to modify it. Once
> it is non-null, its keys and values can be modified. But even a
> non-null AA cannot be reassigned by passing it without ref.
>
> Note that an AA can be constructed using `new` before passing
> by value. See:
> https://dlang.org/spec/hash-map.html#construction_and_ref_semantic
I'll try that, thanks.
More information about the Digitalmars-d-learn
mailing list