-
Notifications
You must be signed in to change notification settings - Fork 3
Enum
Chung Leong edited this page Feb 10, 2024
·
8 revisions
Zig enums are represented as unique objects in JavaScript.
const std = @import("std");
pub const Pet = enum { dog, cat, dragon };
pub fn print(pet: Pet) void {
std.debug.print("pet = {s}\n", .{@tagName(pet)});
}
import { Pet, print } from './enum-example-1.zig';
console.log(typeof Pet.dog);
print(Pet.dog);
print(Pet.cat);
object
dog
cat