Using null inside Coldfusion Array

arrays, coldfusion, coldfusion-9, null

Solution

ColdFusion does not have a null per se. Depending on what uses this variable, one or more of the following may be useful:

- Use a javaNull: `<cfset javaNull = javaCast( "null", 0 ) />`

- Use a blank: `""`

- Use an empty struct ie `{}`

Ben Nadel has some comments on this too.

Problem

I'm creating a array and need use null values ``` <cfset addLinha[1] = qEspecialidades.especialidade> <cfloop index="i" from="1" to="#numColumnsAntes#"> <cfset arrayAppend(addLinha,null)> </cfloop> <cfset arrayAppend(addLinha,LSParseNumber(LSNumberFormat(AvgNota, "_.__")))> <cfloop index="i" from="#numColumnsDepois#" to="#qEspecialidades.RecordCount#"> <cfset arrayAppend(addLinha,null)> </cfloop> ``` I need a array something like this ``` ["Especialidade",null,null,null,null,4.0,null,null,null] ``` But I haven't found how to append `null`.

Original source