lloyAlloy on GitHub
Symbol
Docs

Symbol

Updated
Symbol
import { Symbol } from "@alloy/std/collections"

local key = new Symbol("name")
local t = { [key] = 1 }

A unique key that no string can collide with, from the std: a frozen table that prints as Symbol(name). Use one for a private table slot, or a sentinel a value cannot forge.

Statics

Symbol.new

Symbol.new(name: string)

A unique frozen table that no string can collide with. It prints as Symbol(name), and name is a label alone: two symbols of one name are still two keys.

import { Symbol } from "@alloy/std/collections"

local key = new Symbol("slot")
local t = { [key] = 1 }
print(t[key])