Breadcrumbs

compact() Operation

Removes NULL elements of an array.

Syntax

anArray.compact()

Semantics

Removes NULL elements of the array anArray.

This is a convenience operation that can be used instead of select from anArray where element.exists();.

Substitutables

anArray

Can be any variable or object attribute having the type Array.

Examples

Input: an array of names

JSON
{"names": ["Irene", null, "Raymond", "Jane", null]}
set compactNames = names.compact();

Result:

JSON
{"compactNames": ["Irene", "Raymond", "Jane"]}
📗

Related Pages: