How to update Associative Array?

tastyminerals tastyminerals at gmail.com
Thu Feb 10 12:08:07 UTC 2022


On Thursday, 10 February 2022 at 12:04:04 UTC, bauss wrote:
> On Thursday, 10 February 2022 at 10:59:17 UTC, tastyminerals 
> wrote:
>> [...]
>
> You can just do:
>
> aa[key] = value.
>
> If the key exist then it's updated, if it doesn't then it's 
> added.
>
> The reason for the update function is simply in cases where you 
> want to use the oldvalue etc. perhaps it has a timestamp that 
> you need to keep etc.
>
> But in general you shouldn't need it.

I meant a different thing though. I am looking for 
`mydic.update(another_dic)` analogue where `{"a": 1, "b": 2}` 
update `{"c": 3, "a": -1}` becomes `{"a":-1, "b": 2, "c": 3}`.


More information about the Digitalmars-d-learn mailing list