Hello,
I was curious if it was possible to dynamically create an implicit structure where you might occasionally want to omit some keys from being added to the structure?
I played around with using ternary operators in the structure creation with no luck.
<cfset temp = {
name = "Dave",
(1 IS 1 ? "" : Job = "Superhero")
} />
The only way I can see doing this now would be to create the structure and then use StructKeyDelete on the keys I want to remove OR build structures the traditional way and cfif my way around the keys I don't want to add."
Ex: <cfset structKeyDelete(temp,"Job") />
or
<cfset temp = structNew() />
<cfset temp.name = "Dave" />
<cfif 1 NEQ 1>
<cfset temp.job = "Superhero" />
</cfif>
Does anyone know how to create dynamic keys in a structure while defining it implicitly?
Thanks!