The Ternary Operator and Railo

The Ternary Operator and Railo

With CF9 beta out the blogs have been busy looking at all the new features. There has been some great reads and they've substituted for the fact that I haven't had the time to look at the new version myself yet.

Whats also been a good experience is that they have given me the chance to learn new stuff about Railo that I hadn't realised. The first one is that it already has Ternary Operator. This is a way of writing an IF/ELSE block in a single statement:

[sourcecode language="plain"] $variable = condition ? if true : if false [/sourcecode]

So in my CFSCRIPT block I have:

[sourcecode language="plain"] <cfscript> val = (true ? "A True Response" : "A False Response"); writeOutput(val); </cfscript> [/sourcecode]

Posted: 19-Jul-2009

View: 1258

Permalink: here

Comments

[...] I found the Ternary Operator on Railo I’ve decided to have a look over the Tags documentation, and Functions documentation viewer [...]

Pretty nifty syntax and has been long expected

#2 William from Lagos
20/Jul/09 12:38 PM

This was added to CF9 because the CFML Advisory Committee voted it a core language feature. Same with cfimap.

#3 Sean Corfield
03/Aug/09 6:18 AM