In Zig, values can be assigned to constants or variables. |
|
const std = @import("std"); |
|
pub fn main() !void { |
|
Here, we assign the value |
const c: bool = true; |
Here, we assign the value |
var v: bool = false; v = true; |
Note that the compiler can often infer types for you. |
const inferred = true; |
To create an uninitialized constant or variable, assign |
var u: bool = undefined; u = true; |
Assignments can also be used to ignore expressions. |
_ = c; _ = inferred; } |
Next example: Integers.