how to filter associative arrays with foreach ?

someone someone at somewhere.com
Mon Jun 21 22:34:39 UTC 2021


On Monday, 21 June 2021 at 22:08:56 UTC, Steven Schveighoffer 
wrote:

> It's actually visually shorter than doing the filter.

Indeed; in a few very-specific situations I usually write code 
like this since it allows me to concentrate on the task at hand 
and not on the details to access the needed data, but for the 
clarity of the example I reformatted my code :)

Same when I code RO properties for classes, I usually do:

```d
private pxxxWhatever1; public whatever() @property { return 
pxxxWhatever1; }
private pxxxWhatever2; public whatever() @property { return 
pxxxWhatever2; }
private pxxxWhatever3; public whatever() @property { return 
pxxxWhatever3; }
```

It is far easier to read large chunk of similar constructs 
alongside than one below the other, at least, to me.



More information about the Digitalmars-d-learn mailing list