SplitScript reference / Set / insert

Set.insert

Method

Set<T>.insert(value: T) -> bool where T: Equatable

Inserts a value if it is not already present.

Returns whether the value was newly inserted. A successful insertion invalidates active iteration of this set; inserting an existing value does not.

Parameters

  • value: The value to insert.

Effects: allocates, mutates the receiver

Runtime behavior: available everywhere; synchronous

Examples

Record a visited room

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