Stdle #90 · comptime · 2026-09-04
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 T = struct { fn isEven(n: u32) bool { return n % 2 == 0; } }; const arr = [_]u32{ 1, 2, 3, 4, 5 }; var count: u32 = 0; for (arr) |v| { if (T.isEven(v)) count += 1; } std.debug.print("{d}\n", .{count});}Comptime