typeover
curriculum

Curriculum Basics Functions exercise 5 · fill-word

Functions

Fill the missing visibility modifier. The function will be called from another module, so it has to be exported. Three letters in Zig — shorter than most C-family languages.

TypeScript reference
Fill the blanks →

About this theme

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.