Convert to set

Syntax

	$expr.toSet()

Description

Converts the result of the evaluation of expr into a set. The following cases can occur:

  1. expr is already a set: expr is returned
  2. expr is any collection (e.g. list): expr is converted to a set, removing duplicate elements
  3. expr is null: an Empty set is returned
  4. 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