Curriculum Memory Ownership conventions
Ownership conventions
Zig has no borrow checker — ownership is convention, not enforcement. The rule that makes manual memory livable: whoever calls init is responsible for calling deinit. A function that allocates and returns ownership uses errdefer to clean up on failure; the caller then defers the deinit. A function that borrows takes a slice or pointer and never frees. Once these conventions become reflex, manual memory feels almost as easy as garbage collection — minus the runtime cost.
9 ready
01
pick oneTypeScript's garbage collector hides ownership. Zig surfaces
02
pick oneTypeScript functions that READ a collection just receive the
03
pick one TypeScript's String.prototype.toUpperCase() returns a new
04
fill blanksFill the missing cleanup keyword for the FACTORY function
05
fill blanksFill the missing cleanup keyword for the CALLER who took
06
type one lineType the missing Zig line — schedule the cleanup that the
07
type one line Type the missing Zig signature — the lengthOf function
08
write a programWrite a complete Zig program demonstrating the
09
write a programWrite a complete Zig program demonstrating the BORROW