SplitScript reference / Set

Set

type constructor

Set<T where Equatable>

Stores a growable collection of unique values for one script instance.

A set keeps its allocation and contents across ticks. Mutating operations update the same set value, so a global set can track visited checkpoints without rebuilding a collection on every update.

Examples

Track visited rooms

let visited = Set.new<String>()
visited.insert("Atrium")

Methods

MemberDescriptionAvailable through
clearRemoves every stored value while retaining the set itself.
containsReports whether an equal value is present.
insertInserts a value if it is not already present.
isEmptyReports whether the set contains no values.
iteratorCreates an independent cursor over this set.
lengthReturns the number of stored values.
newCreates an empty set.
removeRemoves an equal value if it is present.