Hi,
I'm getting this error when trying to convert the index from a for loop into a float.
const row = [_]u8{'x', 'y', 'z', 'p'};
pub fn main() !void {
for (row) |tile, index| {
// this works
// const x: usize = 5;
// _ = index;
// this doesn't work
const x = @as(f32, index);
std.debug.print("tile: {c}, x: {d:0.2}\n", .{tile, x});
}
}
The error I get is:
const x = @as(f32, index);
^~~~~
What I find weird is that it works using another usize like in the commented part, but with the index it doesn't.
I'm using the latest zig master. Am I doing something wrong or is this a bug in zig?