On Monday, 21 June 2021 at 03:59:10 UTC, someone wrote:
Is there a way to filter the collection at the foreach-level to avoid the inner if ?

Here's how I would do it:

foreach (k, v; coll) {
    if (k == unwanted) continue;
    ...
}

You still have an if, but the actual loop body doesn't have to be nested, so it's easy to follow the control flow.

Reply via email to