When is an array element not an array element? When it has never been used or initialized. ColdFusion expands arrays dynamically and as needed. So if you assign a value to array[2] after you create the array, ColdFusion will create elements 1 and 2 for you. But only element 2 will be a valid useable element. If you try to access (or even do an IsDefined()) on element 1 CF will throw an error. For this reason it is good practice to always initialize array elements with some value (perhaps “”). (Applies to: ColdFusion All)
Leave a Reply