Curriculum Basics Functions
Functions
Zig functions look like TS with the type annotations shifted: fn name(param: Type) ReturnType { ... }. Visibility is opt-in via pub fn — top-level functions are private by default. Zig has no tuple-return; multi-return uses a struct (the Zig idiom) or out-params. Function-level errors come later in the errors module; here we focus on the value-returning shape.
9 ready
01
pick one TypeScript writes function add(a: number, b: number): number.
02
pick one Zig's functions are PRIVATE by default — the pub keyword opts
03
pick one TypeScript returns multiple values as a tuple [a, b]. Zig
04
fill blanksFill the missing keyword that declares a function. Two letters,
05
fill blanksFill the missing visibility modifier. The function will be
06
type one line Type the missing Zig function signature. The function add
07
type one line Type the missing Zig line — the call to greet that passes the
08
write a programWrite a complete Zig program that:
09
write a programWrite a complete Zig program that returns TWO values via a