Populating nested AAs; "This wouldn't be so verbose in Ada 2020"

mipri mipri at minimaltype.com
Sun Dec 8 06:58:14 UTC 2019

On Sunday, 8 December 2019 at 06:42:22 UTC, Paul Backus wrote:
> You can use the `require` function [1] for this:
> with (userHistory.require(host).require(user)) {
>     if (isOk) ++ok; // renamed to avoid shadowing
>     else ++evil;
> }
> Many "methods" for built-in AAs are located in the `object` 
> module. It makes them a bit tricky to find in the 
> documentation, if you don't already know they're there.
> https://dlang.org/phobos/object.html#.require

Thanks! I wasn't aware of the 'object' doc. Looks like the
language documentation does mention require() in "Inserting if
not present", but combining it with 'with' is a neat trick.

More information about the Digitalmars-d-learn mailing list