Learning Zig from the official language reference.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
zig-langref/assignment.zig

24 lines
431 B

const std = @import("std");
const testing = std.testing;
test "const and var" {
const foo = 12345;
var bar: i32 = 1;
bar += 1;
testing.expect(foo == 12345);
testing.expect(bar == 2);
// this works too
comptime var baz = 99;
comptime {
baz += 1;
}
testing.expect(baz == 100);
}
test "undefined" {
var undef: i32 = undefined;
undef = 99;
testing.expect(undef == 99);
}