access foreach index counter for Iterate n times

Nick Treleaven nick at geany.org
Sat May 21 14:28:00 UTC 2022


On Saturday, 21 May 2022 at 02:35:37 UTC, Mike Parker wrote:
> You get indexes in a foreach with arrays and associative arrays 
> because they have indexes. You don't get them with input ranges 
> because they have no indexes (hence, the need for enumerate).

`iota` with integer arguments produces a random access range, 
which is indexable. It would be nice if `foreach` supported an 
`index, element` pair with RA ranges, when `front` just returns 
an element, not a tuple.


More information about the Digitalmars-d mailing list