-
Notifications
You must be signed in to change notification settings - Fork 3
Null
Chung Leong edited this page Apr 28, 2024
·
4 revisions
The literal null in Zig is represented as null
in JavaScript. You will only encounter it if
you explicitly export null
.
pub const Null = null;
import { Null } from './null-example-1.zig';
console.log(Null);
null
As @TypeOf(null)
is a comptime type, you can only put it into a struct
if you make it
a comptime field:
pub const NumberAndNothing = struct {
number: i32,
comptime nothing: @TypeOf(null) = null,
};
import { NumberAndNothing } from './null-example-2.zig';
const struct = new NumberAndNothing({ number: 1234 });
console.log(struct.valueOf());