I found this rather interesting. If you want to create nested associative arrays in many languages you can easily embed one within another on the same line when declaring it. Unfortunately, it appears this is not true of ColdFusion when using the { } bracket notation in CF8.
For example, lets say you want to create a struct that looks like this:

You might try the following:
1<cfset uploadstr = {uploadid="#form.uploadid#", uploadinfo={tempname="#cffile.serverDirectory##cffile.serverFile#", maxsize="#cffile.fileSize#"}}>
Unfortunately, when attempting to compile the template, coldfusion raises an exception with the nested brackets. You must define the inner structures first like this:
1 2<cfset uploadinfostr = {tempname="#cffile.serverDirectory##cffile.serverFile#", maxsize="#cffile.fileSize#"}> <cfset uploadstr = {uploadid="#form.uploadid#", uploadinfo=uploadinfostr}>

No Comments, Comment or Ping
Reply to “creating nested structures using { } brackets”