I am copying bytes from one array to another:
const std = @import("std");
const print = std.debug.print;
pub fn main() void {
const s1: [3]u8 = .{1,2,3};
var s2: [3]u8 = .{0,0,0};
for (s1) |x, k| {
s2[k] = x;
}
print("{any}\n", .{s2});
}
With zig 0.10 the program works as was intended:
$ ./c
{ 1, 2, 3 }
With zig 0.11 and 0.12 I got an error:
$ /opt/zig-0.12/zig build-exe c.zig
c.zig:9:18: error: extra capture in for loop
for (s1) |x, k| {
^
It looks like zig 0.11/0.12 does not want to use k
for indexing an array that is not in for()
What can I do with this?