← Back to archive

Stdle #40 · structs · 2026-07-16

What does this Zig snippet output?

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

const std = @import("std");
const Point = struct {
x: i32,
y: i32,
fn sum(self: Point) i32 {
return self.x + self.y;
}
};
pub fn main() void {
const p = Point{ .x = 10, .y = 20 };
std.debug.print("{d}\n", .{p.sum()});
}
Structs
4 attempts left

Answer & explanation