[SNIPPET] Format List of Values
Posted: 09 Feb 2023, 12:08
The List.joining() and List.joiningDistinct() methods can be used to convert a List object into a String object.
e.g. join season years with dash enclosed in parentheses:
e.g. join unique audio language properties:
Implementation Notes:
Empty elements are ignored:
Empty lists do not yield empty brackets [] and instead unwind the expression:
e.g. join season years with dash enclosed in parentheses:
Format: Select all
{ sy.joining('-', '(', ')') }
Code: Select all
(2002-2003)
e.g. join unique audio language properties:
Format: Select all
{ audio.language.joiningDistinct(', ', '[', ']') }
Code: Select all
[ca, en, es, fr, it, nl]
Implementation Notes:
Empty elements are ignored:
Format: Select all
{ ['1', null, '', '2'].joining('-', '[', ']') }
Code: Select all
[1-2]
Empty lists do not yield empty brackets [] and instead unwind the expression:
Format: Select all
{ [].joining('-', '[', ']') }
Error: Select all
Collection did not yield any values: []