#Loop over iterator get index
1 messages · Page 1 of 1 (latest)
TL;DR: With a while loop, no.
The thing is, when you use an iterator and a while loop with next(), zig itself has no knowledge of what you are iterating over, it just calls the next function and gives it to you. The while loop just checks the condition before running the content of the loop.
Iterating with a for loop gives the compiler context that you are iterating over a slice []T of some type T, it has more context to work with and you can get an index if you want.