Interner
Gives each distinct string a number, and turns the number back into the string. Numbers start at 1 and follow the order strings are first seen, and a string is never removed.
local Names = Collections.Interner.new()local Id = Names:Intern("goblin")print(Id, Names:KeyOf(Id)) -- 1 goblinSummary
Section titled “Summary”| Member | Description |
|---|---|
.new() |
Creates an empty interner. |
:Intern() |
Returns Key’s number, giving it the next one if it has none. |
:KeyOf() |
Returns the string numbered Id, or nil if no string has that number. |
:Count() |
How many distinct strings it holds. |
Interner |
The type Interner.new returns. |
Functions
Section titled “Functions”function Interner.new(Config: { InitialCapacity: number? }?): InternerCreates an empty interner.
Methods
Section titled “Methods”Intern
Section titled “Intern”function Interner:Intern(Key: string): numberReturns Key’s number, giving it the next one if it has none. Errors if Key is not a string.
function Interner:KeyOf(Id: number): string?Returns the string numbered Id, or nil if no string has that number.
function Interner:Count(): numberHow many distinct strings it holds.
Interner
Section titled “Interner”export type Interner = {
Intern: (self: Interner, Key: string) -> number,
KeyOf: (self: Interner, Id: number) -> string?,
Count: (self: Interner) -> number,
}The type Interner.new returns.
© 2026 PRMS Developer