Implicit Structure behaviour change in CF9
Posted by Steve Onnis at 4:23 PM
0 comments - Categories:
Coldfusion
The introduction of ColdFusion 8 saw the addition of implicit structure creation where by you could easily create structures by using {} to create the structure key/value pairs.
For example<cfset struct = {firstname = "Steve", lastname = "Onnis"} />
Now you notice that example ColdFusion 8 does not allow the key to be quoted. This means the the following
<cfset struct = {"firstname" = "Steve", "lastname" = "Onnis"} />
generates this error
ColdFusion was looking at the following text:
{
This means that you cannot have a structure created in this way that has keys with spaces in them.
ColdFusion 9 however seems to have changed the manner in which this behaves. ColdFusion 9 implicit structures now allow you to use quoted values for structure keys when creating structures implicitly.
For example<cfset struct = {"First Name" = "Steve", "Last Name" = "Onnis"} />
Not sure if this is on purpose as the ColdFusion 9 docs don't mention any change in the behaviour but it is certainly something to look out for.