Iteration order in for loop

Is the iteration order specified to be ascending in a for loop? How can one use a for loop to iterate descendingly?

Thanks.

// forward
for (slice) |element| {
}

// backward
{
    var i = slice.len;
    while (i > 0) : (i -= 1) {
        const element = slice[i-1];
    }
}
1 Like