← Back to archive

Stdle #132 · structs · 2026-10-16

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 Pair = struct { a: i32, b: i32 };
const pairs = [_]Pair{
.{ .a = 1, .b = 10 },
.{ .a = 2, .b = 20 },
.{ .a = 3, .b = 30 },
};
var sum: i32 = 0;
for (pairs) |p| {
sum += p.b;
}
std.debug.print("{d}\n", .{sum});
}
Structs
4 attempts left

Answer & explanation