Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 150094

Re: Dynamic Implicit Structure Creation Question

$
0
0

I can think of at least one reason why this fails. If there is just one key-value pair, there will be a comma stranded at the end.

 

You can of course tinker dynamically with the content of the keys of a struct and their respective values. However, a struct is an object, with set characteristics such as number of key-value pairs. So, it would be difficult to dynamically change the number of key-value pairs 'from within' the struct. Even if what you are trying to do were possible, it would be more complex, and would certainly involve more code, than the ordinary alternative you mention.

 

In any case, here is a version of your original idea that works:

 

<cfset temp = (1 IS 2 ? {name="Dave"} : {name="Dave",Job="Superhero"})>

<cfdump var="#temp#">


Viewing all articles
Browse latest Browse all 150094

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>