Feature to get or add value to an associative array.

ag0aep6g anonymous at example.com
Wed Apr 18 16:47:50 UTC 2018


On 04/18/2018 11:41 AM, Nick Treleaven wrote:
> How do you implement this if the function returns with ref:
> 
> bool inserted;
> auto p = aa.slot("key", &inserted);
> if (inserted) {
>    ...
>    // set *p
> }
> else {
>    // read *p
>    ...
>    // set *p
> }

You can get a pointer from the ref return:

     Value* p = &aa.slot("key", { inserted = true; return Value.init; });

Then do with the pointer whatever you want.


More information about the Digitalmars-d mailing list