foreach automoatic counter?

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Sep 22 06:05:31 PDT 2015


On 9/21/15 6:49 PM, Jonathan M Davis via Digitalmars-d-learn wrote:
> In general though, if you want a counter for the
> range that you're indexing, then you can use lockstep to wrap the range, and
> then when you use it in foreach, you get the count and the element:
>
> http://dlang.org/phobos/std_range.html#.lockstep

As Justin Whear pointed out, enumerate is better when you have one range.

-Steve


More information about the Digitalmars-d-learn mailing list