Interesting change with listToArray from ColdFusion 8 to 9

This post is more than 2 years old.

Sorry if I'm late in noticing this - but something odd has happened with listToArray. I was reviewing SVN commits at work today when I noticed a coworker checked in a file where he stated that he had to modify a listToArray call because of "some change" to listToArray in ColdFusion 9. Now - I knew that listToArray changed in CF9. The reference shows that the multiCharacterDelimiter argument was added in CF9. However, in both CF8 and 9, the 3rd argument, includeEmptyFields, defaults to false.

So, given the following string:

<cfset str = ", A , B , , , 0"> <cfset arr = listToArray(str)> <cfdump var="#arr#">

I'd expect an array with 3 items: A, B ,0. However, in ColdFusion 8, the array contains A, B, 2 empty elements, and 0. I then noticed something. The list items weren't empty - they had a space. Technically, that's content. Now practically I can see why it is treated as empty content, but this was a surprising change since - for the most part - Adobe treats backwards compatability as something close to the Prime Directive. Personally I think CF8 is doing the right thing.

I can say that when ignoreEmptyFields is set to true, both CF8 and 9 return the exact same array.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by Rick O posted on 6/5/2010 at 12:32 AM

Halle-frickin-lujia. I, for one, welcome our new finally-working-right-screw-compatibility listToArray overlords.

I rewrote my own listToArray workaround for more projects than I want to think about. I have yet to work on a project where the old "silently drop empty elements" mis-feature would have been useful. If some later commenter would care to enlighten me as to why the old way was A Good Thing, I'd be happy to listen.

Comment 2 by Adam Cameron posted on 6/5/2010 at 12:36 AM

Interesting... I agree CF8's behaviour makes the most sense. So CF9 should be doing the same both for the sake of "most sense" and "backwards compat".

Maybe there's a fix on the horizon though... I see there's an issue covering this in the bug tracker - - which is marked as verified & closed. Whilst there's no way to interpret what "closed" means, hopefully it's closed because it's been fixed in 9.0.1, which - according to the Adobe bods who were in London for Scotch on the Rocks recently - is due out in the latter part of this year.


Comment 3 by Raymond Camden posted on 6/5/2010 at 12:51 AM

I can confirm - fixed in 901. (Just asked permission to 'leak' this so please don't consider it a NDA breach. ;)

Comment 4 by Rick O posted on 6/5/2010 at 12:57 AM

Oh. Ack. Arg. I misread your post. I retract my celebration.

I didn't realize they'd fixed it in CF8, then reverted the fix in CF9.

sane: arrayLen(listToArray("1, ,3")) eq 3

Silently eliminating elements is scary nuts.

Comment 5 by Mihai Baboi posted on 6/5/2010 at 4:58 PM

I love the way you digg deep in the ColdFusion core and explain functions that I just take for granted. Thanks for the heads-up.

Comment 6 by Ben Riordan posted on 6/6/2010 at 7:11 AM

@Ray If you can "leak" 9.0.1 details do you have any permission to "leak" 9.0.1 release time frame? ;-D (can't hurt to ask can it?)

Comment 7 by Raymond Camden posted on 6/6/2010 at 7:41 PM

CF901 will be released on a day that ends with "y".

Comment 8 by Ben Riordan posted on 6/6/2010 at 7:58 PM

Yes! Awesome intel. Thanks ray.

Comment 9 by Ben Riordan posted on 6/6/2010 at 7:59 PM

*Ray - You get capital R.

Comment 10 by James Edmunds posted on 6/6/2010 at 8:12 PM

A day that ends in "y"? Aw, shucks, I was hoping for tomorrow.

Comment 11 by Jeff posted on 6/7/2010 at 7:07 PM


It's even better ends in a Y!

Comment 12 by Joshua Belliveau posted on 7/20/2010 at 5:37 AM

Thanks for the heads-up Ray.

FYI, you reference "includeEmptyFields" in your first paragraph and "ignoreEmptyFields" in your last. Was that intentional?

Comment 13 by Raymond Camden posted on 7/20/2010 at 5:57 AM

It's definitely includeEmptyFields. Pardon the brain fart. :)