Why does arrayAppend return true and listAppend return the list?

coldfusion

Solution

This is because there is no "List" data type in ColdFusion.

A "List" is a delimited string, simple as that. It is comma-delimited by default, but you can choose the delimiter. "`ListAppend()`" is a string concatenation operation, and as such it returns the result of its work just like "`string1 & string2`" would.

The only thing that "`ListAppend()`" does for you is: It takes care of the delimiter handling, preventing needless double delimiters - something that "`string1 & string2`" cannot do.

An array is a real data type and (in contrast to a string) can be modified in-place. This is what `ArrayAppend()` does.

Problem

In ColdFusion, the arrayAppend() function takes an array and an item to be appended. It modifies the array that was passed in and returns true if successful. The listAppend() function, however, takes a list and an item to be appended, and returns a new list with the item appended. It doesn't modify the list that was passed in. Why do these functions operate in two different ways? I'm always turning to the documentation to remember the return value of each.

Original source