access foreach index counter for Iterate n times

mw mingwu at gmail.com
Sat May 21 02:41:04 UTC 2022


On Saturday, 21 May 2022 at 02:35:37 UTC, Mike Parker wrote:
> On Saturday, 21 May 2022 at 02:23:28 UTC, mw wrote:
>
>> My point: the language should be more consistent.
>
> 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). 
> So is it really in consistent that a numeric range of 0 .. N 
> has no index?

More abstractly, it's not array/range index, it's a loop counter 
(index).



More information about the Digitalmars-d mailing list