An optional type is a type that can hold either a value or no value.
| Section | Title |
|---|---|
| 1 | Optional Types |
| 2 | Optional Unwrapping |
| 3 | Nullable Pointers |
| 4 | Vectors |
| 5 | Opaque Types |
| 6 | anytype |
| 7 | Error Union Internals |
| 8 | Type Coercion |
| 9 | Type Reflection Basics |
Optional TypesAn optional type is a type that can hold either a value or no value.
Optional UnwrappingOptional unwrapping means taking the value out of an optional.
Nullable PointersA pointer stores the address of a value in memory.
VectorsA vector is a fixed-size group of values of the same type.
Opaque TypesAn opaque type is a type whose internal structure is hidden.
`anytype`anytype means the function parameter can accept many different types.
Error Union InternalsAn error union is a value that can contain either:
Type CoercionType coercion means Zig converts a value from one type to another when the conversion is safe and well-defined.
Type Reflection BasicsType reflection means asking questions about a type while Zig is compiling the program.