Sets

Sets

> LeekScript

A set is a structure for storing distinct values. Unlike in a list, the elements are therefore unique, but like in a map they are not ordered.

Creation

You can create a set with the following syntax:

A set can contain any type of value:

Reading

Looking up an element takes constant time:

The in operator can also be used:

Modification

Adding an element:

Removing an element:

Operations

The possible operations on sets are union, intersection, difference and disjunction:

Iteration

You can iterate over the elements of a set, in no particular order: