Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Ternary conditional operator
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
====Lucee, Railo, and ColdFusion 11-specific==== [[Lucee]], [[Railo]], and ColdFusion 11 also implement the Elvis operator, {{code|?:}} which will return the value of the expression if it is not-null, otherwise the specified default. Syntax: <syntaxhighlight lang="CFC"> result = expression ?: value_if_expression_is_null </syntaxhighlight> Example: <syntaxhighlight lang="CFC"> result = f() ?: "default"; // where... function f(){ if (randRange(0,1)){ // either 0 or 1 (false / true) return "value"; } } writeOutput(result); </syntaxhighlight> The function {{code|f()}} will return {{code|value}} roughly 50% of the time, otherwise will not return anything. If {{code|f()}} returns "value", {{code|result}} will take that value, otherwise will take the value "default".
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)