🚀 Welcome to MDriven Learn –  Don’t miss the latest Release Notes.
OCLOperators asSeparatedList


The asSeparatedList() operator converts a collection into a single string, where each element is represented as text and separated by a specified delimiter. This operator is especially useful for display purposes, such as showing a list of values in the UI, generating readable labels, or producing formatted output for reports.

Example:

The ->asSeparetadList(separatorstring) operator works on a set of strings and appends them to one string:

Set{'x','y','x'}->asSeparatedList( '_')

Will produce the string x_y_z.

asSeparatedList() on a collection

Syntax

collection->asSeparatedList('separator')

Example:

Department.allInstances->collect(DepartmentName)->asSeparatedList(', ')

Results:

Error creating thumbnail: File missing







Each element in the collection is automatically converted to a string (using asString) before being joined together.

See also: asCommaList