Re: How come a count of a range becomes 0 before a foreach?

2023-04-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/10/23 6:43 PM, ikelaiah wrote: On Monday, 10 April 2023 at 01:01:59 UTC, Steven Schveighoffer wrote: On 4/9/23 9:16 AM, Ali Çehreli wrote:    auto entries = dirEntries(/* ... */).array; I'd be cautious of that. I don't know what the underlying code uses, it may reuse buffers for e.g.

Re: How come a count of a range becomes 0 before a foreach?

2023-04-10 Thread ikelaiah via Digitalmars-d-learn
On Monday, 10 April 2023 at 01:01:59 UTC, Steven Schveighoffer wrote: On 4/9/23 9:16 AM, Ali Çehreli wrote: On 4/8/23 21:38, ikelaiah wrote: > I will modify the code to construct it twice. Multiple iterations of dirEntries can produce different results, which may or may not be what your prog

Re: How come a count of a range becomes 0 before a foreach?

2023-04-10 Thread ikelaiah via Digitalmars-d-learn
On Sunday, 9 April 2023 at 13:16:51 UTC, Ali Çehreli wrote: On 4/8/23 21:38, ikelaiah wrote: > I will modify the code to construct it twice. Multiple iterations of dirEntries can produce different results, which may or may not be what your program will be happy with. Sticking an .array at t

Re: How come a count of a range becomes 0 before a foreach?

2023-04-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/9/23 9:16 AM, Ali Çehreli wrote: On 4/8/23 21:38, ikelaiah wrote: > I will modify the code to construct it twice. Multiple iterations of dirEntries can produce different results, which may or may not be what your program will be happy with. Sticking an .array at the end will iterate a

Re: How come a count of a range becomes 0 before a foreach?

2023-04-09 Thread Ali Çehreli via Digitalmars-d-learn
On 4/8/23 21:38, ikelaiah wrote: > I will modify the code to construct it twice. Multiple iterations of dirEntries can produce different results, which may or may not be what your program will be happy with. Sticking an .array at the end will iterate a single time and maintain the list forev

Re: How come a count of a range becomes 0 before a foreach?

2023-04-08 Thread ikelaiah via Digitalmars-d-learn
On Sunday, 9 April 2023 at 03:39:52 UTC, Steven Schveighoffer wrote: On 4/8/23 9:38 PM, ikelaiah wrote: // Get files in specified inputPath variable with a specific extension     auto rmdFiles = file.dirEntries(inputPath, file.SpanMode.shallow)     .filter!(f => f.isFile)     .filte

Re: How come a count of a range becomes 0 before a foreach?

2023-04-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/8/23 9:38 PM, ikelaiah wrote: // Get files in specified inputPath variable with a specific extension     auto rmdFiles = file.dirEntries(inputPath, file.SpanMode.shallow)     .filter!(f => f.isFile)     .filter!(f => f.name.endsWith(fileEndsWith));     // LINE 72 -- WARNING -- I

How come a count of a range becomes 0 before a foreach?

2023-04-08 Thread ikelaiah via Digitalmars-d-learn
Hi, I've written a file that converts Rmd (R Markdown file), to a MarkDown file. All works well if and only if line 73 is commented out. I marked line 72 in the code below. If line 73 is not commented out, `foreach` does not execute as the `rmdFiles.walklength` in line 82 becomes `0`. How