how to skip the next (n) item & continue from (n+1) with a range ? e.g. in File(fn).byLine();

mw mingwu at gmail.com
Mon Jun 22 19:53:27 UTC 2020


Hi,

I need this logic:

```
auto range = File(fn).byLine();
foreach (line; range) {
   if (comeCond(line)) {
      // skip the next n line
      // and continue the foreach loop from the (n+1) line
   } else {
      regularProcess(line);
   }
}
```

Is it possible to do this in a foreach loop?

If not, how can I achieve that, esp. when reading a file 
line-by-line?
do I have to read the whole file into memory, and split by line 
and using regular `for` loop?



More information about the Digitalmars-d-learn mailing list