OCLOperators asSeparatedList
Created by Hans.karlsen on 2018-08-05 · Last edited by Colline.ssali on 2025-12-27.
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:
Each element in the collection is automatically converted to a string (usingasString) before being joined together.
See also: asCommaList
