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

ikelaiah iwan.kelaiah at gmail.com
Mon Apr 10 21:54:51 UTC 2023


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 the end will iterate a single time and 
> maintain the list forever because .array returns an array. :)
>
>   auto entries = dirEntries(/* ... */).array;
>
> Ali


Ali,

I didn't think about returning `dirEntries` as `array`.
Thanks for the Gems (and your online book too).

Regards,
ikelaiah




More information about the Digitalmars-d-learn mailing list