Click to search Andy Jarrett.co.uk RSS feed

Loading Twitter

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]

Comments Comments (3) | Print Print | Send Send | 506 Views

(Comment Moderation is enabled. Your comment will not appear until approved.)
[...] 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
This was added to CF9 because the CFML Advisory Committee voted it a core language feature. Same with cfimap.
BlogCFC by Raymond Camden + Twitter @AndyJ + ColdFusion jobs + Contact Me + Snippets/Downloads + RSS .