On 6/9/20 7:53 PM, Q. Schroll wrote:
Is there any particular reason why std.range : enumerate is a thing and

     foreach (i, e; range) { ... }

doesn't work from the get-go? I wouldn't have such an issue with it if static foreach would work with enumerate just fine.

What is the use case for static foreach and enumerate?

My biggest problem with enumerate is that you can't bind the tuple to parameters for something like map:

arr.enumerate.map!((idx, val) => ...)

doesn't work. Instead you have to do:

arr.enumerate.map!((tup) => ...)

And use tup[0] and tup[1].

-Steve

Reply via email to