A program stores values so it can use them later. In Zig, you store values with two main keywords:
| Section | Title |
|---|---|
| 1 | Variables and Constants |
| 2 | Primitive Types |
| 3 | Integer Types and Overflow |
| 4 | Floating Point Numbers |
| 5 | Booleans and Comparisons |
| 6 | Type Inference |
| 7 | Undefined Values |
| 8 | Zero Values and Initialization |
| 9 | Strings and UTF-8 |
| 10 | Comments and Documentation |
| 11 | Naming Conventions |
| 12 | Reserved Keywords |
Variables and ConstantsA program stores values so it can use them later. In Zig, you store values with two main keywords:
Primitive TypesEvery value in a Zig program has a type.
Integer Types and OverflowIntegers are whole numbers.
Floating Point NumbersFloating point numbers are numbers with fractional parts.
Booleans and ComparisonsA boolean is a value that can be only one of two things:
Type InferenceType inference means Zig can figure out a type from the value you write.
Undefined ValuesIn Zig, undefined means “this value has not been initialized.”
Zero Values and InitializationInitialization means giving a value to something when it is created.
Strings and UTF-8A string is text.
Comments and DocumentationComments are notes for humans who read the code.
Naming ConventionsNames are part of the program.
Reserved KeywordsA keyword is a word that has special meaning in Zig.