Why is there no range iteration with index by the language?

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Jun 10 00:16:01 UTC 2020


On Tue, Jun 09, 2020 at 05:03:55PM -0700, H. S. Teoh via Digitalmars-d-learn wrote:
> On Tue, Jun 09, 2020 at 11:53:16PM +0000, Q. Schroll via Digitalmars-d-learn 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?
> [...]
> 
> std.range.indexed is your friend. ;-)
[...]

Aaah, that function doesn't do what I thought it did.  Sorry!! :-(

What you want is std.range.enumerate.  But you already knew that.


T

-- 
EMACS = Extremely Massive And Cumbersome System


More information about the Digitalmars-d-learn mailing list