Today I attempted to create a struct in ColdFusion 8 via shorthand using the syntax:
<cfscript> struct = {key1=val1,key2=val2}; </cfscript>
My case was creating a state list with abbreviation for keys and the state name as the value. However I have determined that not all key names can be used. If it is a reserved ColdFusion word, it may not work. For example “IN” and “OR”.
What I want:
<cfscript> var strStates = {IN="Indiana",OR="Oregon",UT="Utah"}; </cfscript>
But that leaves me with an “Invalid CFML construct found…”.
So as a workaround I did this:
<cfscript> var strStates = {UT="Utah"}; strStates["IN"] = "Indiana"; strStates["OR"] = "Oregon"; </cfscript>
So much for shorthand. Has anyone found a better solution for this?