I can't believe after all these years using ColdFusion, that this is the first I've encountered this issue with the way lists are manipulated.

Without actually knowing, it's fairly easy to guess that lists are stored as strings, and the functions which act on them are really just performing string manipulations.

No problems there, we certainly appreciate the quick and easy syntax provided by the List Functions, but there seems to be a small (large depending on your circumstances) issue with the ListGetAt function.

If your list contains an empty string, ListGetAt treats it as if that list element doesn't exist at all. Not expected behavior!

For instance, the following list only has 3 elements in the eyes of ListGetAt:


If your code depends on certain list elements to exist at certain indexes within the list, and there is the potential for an empty string value, you might consider using the following method to insure that there are no empty strings:

<cfset mylist = Replace(mylist, ",,", ", ,", "ALL")>

Essentially, add a space between all double commas.


Leave a Reply

Your email address will not be published. Required fields are marked *