In a ranged loop, why is the start index inclusive of the end index?
Ziggit
In a ranged loop, why is the start index inclusive of the end index?
Given a ranged loop, It is my understanding that the start is inclusive while the end is exclusive. I take this to mean that the start index should always have a valid entry like this ~/Desktop/temp/bench [1] $ tail -n 7 main.zig && zig build-exe main.zig && ./main pub fn main() !void { const array = [_]usize{0}; print("Item: {d}\n", .{array[0]}); for (array[0..], 0..) |n, i| { print("{d}: {d}\n", .{ i, n }); } } Item: 0 0: 0 However, in this case the start index is ...
Given a ranged loop, It is my understanding that the start is inclusive while the end is exclusive. I take this to mean that the start index should always have a valid entry like…
0 comments
No comments yet.