how to filter associative arrays with foreach ?
Elronnd
elronnd at elronnd.net
Mon Jun 21 21:00:42 UTC 2021
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.
More information about the Digitalmars-d-learn
mailing list