foreach thoughts

Artur Skawina art.08.09 at gmail.com
Tue Jan 14 03:57:19 PST 2014


On 01/14/14 09:22, Manu wrote:
> 2. A filter
> 
> The other thing is the ability to skip uninteresting elements. This is typically performed with the first line of the loop testing a condition, and then continue:
> foreach(i, t; things)
> {
>   if(!t.isInteresting)
>     continue;
>   ...
> }
> 
> I'm finding in practise that at least one of these seems to pop up on the vast majority of loops I'm writing. It produces a lot of visual noise, and I'm finding it's quite a distraction from the otherwise relative tidiness of my code.

  foreach(i, t; things) if (t.isInteresting)
  {
     ...
  }

artur


More information about the Digitalmars-d mailing list