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.

Reply via email to