$expr.toSet()
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 is null: an Empty set is returned| Name | Type | Description | Mandatory | Default |
|---|---|---|---|---|
| expr | Number/string/boolean/buisness object/set | An expression whose evaluation is to be converted into a set. | yes |
Type: Set
A set representing the values from expr.
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.
toSet(1)
Output: A set with the element [1].
toSet(null)
Output: An empty set