Ternary conditional operator: Difference between revisions

Content deleted Content added
Oracle SQL: fix syntaxhighlight error
R: fix syntaxhighlight errors
Line 617:
The traditional if-else construct in [[R (programming language)|R]] (which is an implementation of [[S (programming language)|S]]) is:
 
<syntaxhighlight lang="rsplusr">
if (a < b) {
x <- "true"
Line 627:
If there is only one statement in each block, braces can be omitted, like in [[C (programming language)|C]]:
 
<syntaxhighlight lang="rsplusr">
if (a < b)
x <- "true"
Line 636:
The code above can be written in the following non-standard condensed way:
 
<syntaxhighlight lang="rsplusr">
x <- if (a < b) "true" else "false"
</syntaxhighlight>
Line 642:
There exists also the function {{code|ifelse}} that allows rewriting the expression above as:
 
<syntaxhighlight lang="rsplusr">
x <- ifelse(a < b, "true", "false")
</syntaxhighlight>