← Back to archive

Stdle #161 · comptime · 2026-11-14

What does this Zig snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

const std = @import("std");
pub fn main() void {
const buf = comptime blk: {
var b: [5]u8 = undefined;
for (&b, 0..) |*c, i| {
c.* = 'A' + @as(u8, @intCast(i));
}
break :blk b;
};
std.debug.print("{s}\n", .{&buf});
}
Comptime
4 attempts left

Answer & explanation