| Section | Title |
|---|---|
| 1 | The Structure of a Function |
| 2 | Parameter Syntax |
| 3 | The return Keyword |
| 4 | Returning a Struct |
| 5 | A First Example |
| 6 | A First Example |
| 7 | What Anonymous Functions Usually Mean |
| 8 | A Simple Function |
| 9 | A Mental Model |
| 10 | What “Exported” Means |
| 11 | Zig Generics Use comptime |
The Structure of a FunctionFunctions are reusable blocks of code.
Parameter SyntaxFunction parameters are the inputs of a function.
The `return` KeywordFunctions often need to produce results.
Returning a StructMany functions need to produce more than one piece of information.
A First ExampleRecursion is a technique where a function calls itself.
A First ExampleFunctions are values.
What Anonymous Functions Usually MeanAn anonymous function is a function without a permanent name.
A Simple FunctionAn inline function is a function where the compiler may place the function’s code directly at the call site instead of performing a normal function call.
A Mental ModelA calling convention defines how functions communicate at the machine level.
What “Exported” MeansAn exported function is a function made visible outside the current Zig program.
Zig Generics Use `comptime`A generic function is a function that works with many types instead of only one type.