← Back to archive

Stdle #94 · comptime · 2026-09-08

What does this Zig snippet output?

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

const std = @import("std");
fn clamp(comptime T: type, val: T, lo: T, hi: T) T {
return @max(lo, @min(val, hi));
}
pub fn main() void {
std.debug.print("{d}\n", .{clamp(i32, 15, 0, 10)});
}
Comptime
4 attempts left

Answer & explanation