Lucee has lists which are strings with a delimiter (default is a comma). Lists can only contain strings (and they are a string themselves), so use an Array to contain complex data types. Lists are not real objects in Lucee, and are simply strings that contain a delimiter. As such, any string can be a list that has a delimiter other than a zero length string.

All of the list functions precide with "list" in their name. This is to differentiate list functions from string functions, because lists are also strings. So "my,list".len(); returns 7, while "my,list".listLen() returns 2

See the available List functions under the string methods

Create a List

To create a list, create a string with a delimiter. The default delimiter for list functions is a comma, but any delimiter is possible.

Looping over Lists

If the list is comma separated (which is the default delimiter) it is possible to use a for loop:

If the list is not comma separated, convert to commas first with the listChangeDelims() function:

List to Array

Though it is possible to loop over lists and perform operations on lists, it can sometimes be cleaner code to convert to an array first.

results matching ""

    No results matching ""