Published:
Warning: This blog entry was written two or more years ago. Therefore, it may contain broken links, out-dated or misleading content, or information that is just plain wrong. Please read on with caution.
So I was working on some CF10 code the other day after having been doing javascript for a while when I accidentally used the colon character as my separator the same way you do in javascript. It was only later when I was reviewing the code before committing to source control that I realized that it didn't throw any errors and the structures were correctly formed.
I don't know how I missed it but sure enough when I googled it there it was on the ColdFusion 10 Language Enhancements List "Implicit struct now supports use of : (colon) separator"
.
Give it a try
These two structs will be created the exact same way.
<cfset struct1 = {
test = "string1"
,test2 = 2
}>
<cfset struct2 = {
test : "string1"
,test2 : 2
}>
<cfdump var="#struct1#">
<cfdump var="#struct2#">
Going forward
Now I've known that Railo has supported the colon separator since version 3 but I never used it because I switch between CF and Railo on such a regular basis that I try not to use too many engine specific enhancements. So I was pleasantly surprised that CF10 also supports it. Needless to say I may be late to the game on this but I am going to start using this syntax from now on.
Reader Comments