Convert to set
Syntax
$expr.toSet()
Description
Converts the result of the evaluation of expr
into a set. The following cases can occur:
expr
is already a set:expr
is returnedexpr
is any collection (e.g. list):expr
is converted to a set, removing duplicate elementsexpr
isnull
: an Empty set is returned- For all other values a one-element set is created, see Pack
Parameter
Name | Type | Description | Mandatory | Default |
---|---|---|---|---|
expr | Number/string/boolean/buisness object/set | An expression whose evaluation is to be converted into a set. | yes |
Return value
Type: Set
A set representing the values from expr
.
Examples
Conversion of a list
list(1, 1, 2, 3, 3).toSet()
Output: A set with the elements [1, 2, 3].
Duplicate values are removed during conversion, since sets may not contain duplicate values.
Conversion of a scalar value
toSet(1)
Output: A set with the element [1].
Conversion of null
toSet(null)
Output: An empty set