Unfortunately I'm on CF8. And I wonder if the ternary operator would be able to handle a dynamic value as the output as with my example. IIF works perfect for exactly the type of example you gave; a simple boolean evaluated to output a simple string. The problem lies in CF apparently evaluating the two outputs before determining if the StruckKey exists.
On Tue, Sep 7, 2010 at 5:21 PM, Andy Matthews <[email protected]>wrote: > > CF9 has the ternary operator which is awesome. Works like JavaScript: > > <cfset output = (boolean ? "It was True" : "It was False")> > > > > andy > > -----Original Message----- > From: Michael Grant [mailto:[email protected]] > Sent: Tuesday, September 07, 2010 4:17 PM > To: cf-talk > Subject: Re: Finding if a key exists in a struct based on a variable name > > > HA! So I'm not the only one! > So I thought DE meant "Delay Evaluation" as in "Don't evaluate what's in > these little brackets this until you've satisfied the IIF condition." > I guess not? > > On Tue, Sep 7, 2010 at 5:14 PM, Raymond Camden <[email protected]> wrote: > > > > > Bah - I hacked away at it for 10 minutes before remembering why I > > hated IIF/DE in the first place. ;) > > > > On Tue, Sep 7, 2010 at 4:04 PM, Michael Grant <[email protected]> wrote: > > > > > > Try running this: > > > > > > <cfset x = {}> > > > <cfset y = "all"> > > > <cfoutput> > > > #iif(StructKeyExists(x,"#y#head"),DE('yes'),DE('no'))# > > > </cfoutput> > > > <p> > > > <!--- <cfset x["allhead"] = "booger"> ---> <cfoutput> > > > #iif(StructKeyExists(x,"#y#head"),DE(x["#y#head"]),DE('no'))# > > > </cfoutput> > > > > > > > > > > > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336884 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

