Convert to set
Syntax
$expr.toSet()
Description
Converts the result of the evaluation of expr into a set. The following cases can occur:
expris already a set:expris returnedexpris any collection (e.g. list):expris converted to a set, removing duplicate elementsexprisnull: 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