Whatever message this page gives is out now! Go check it out!

ListLast

Last update:
May 18, 2026

Description

Gets the last element of a list.

Returns

The last element of the list.

Category

History
ColdFusion (2018 release): Introduced named parameters.

Function syntax

ListLast(list [, delimiters, includeEmptyFields ])

See also

ListGetAtListFirstLists in Data types- Developing guide in the Developing ColdFusion Applications

Parameters

Parameter
Description
includeEmptyFields
Optional. Set to yes to include empty values.
list
A list or a variable that contains a list.
delimiters
A string or a variable that contains one. Characters that separate list elements. The default value is comma. If this parameter contains more than one character, ColdFusion processes each occurrence of each character as a delimiter; you cannot specify a multicharacter delimiter.

Usage

If you use list functions on strings that separated by a delimiter character and a space, a returned list element might contain a leading space; use the trim function to remove leading and trailing spaces from a returned element. For example, consider this list:
<cfset myList = "one hundred, two hundred, three hundred">
To get a value from this list, use the trim function to remove the space before the returned value:
<cfset MyValue = #trim(ListLast(myList)#>
With this usage, the MyValue variable gets the value "three hundred", not " three hundred", and spaces within a list element are preserved.ColdFusion ignores empty list elements; thus, the list "a,b,c,,,d" has four elements.

Example

<cfscript>
       myList="Tokyo,Bangkok,Jakarta,Manila,Bangalore,Shanghai";
       WriteOutput(ListLast(myList)); //Returns the last element in the list, Shanghai
</cfscript>
Output
Shanghai

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page