Changes

Jump to navigation Jump to search
88 bytes added ,  15:54, 31 October 2018
no edit summary
==Ternary If==
The [https://en.wikipedia.org/wiki/%3F: ternary if] operator provides a short syntax for conditions. It is also called '''conditional operator''' or '''ternary operator'''. In most languages , the syntax is <code>a ? b : c</code>. As <code>?</code> and <code>:</code> have already been taken in XQuery, the syntax of Perl 6 is used:
<pre class="brush:xquery">
==Elvis Operator==
The Elvis operator is also available in other languages; it . It is sometimes called [https://en.wikipedia.org/wiki/Null_coalescing_operator](null-coalescing operator)]. The In XQuery, the value of the first operand will be returned if it is a non-empty sequence. Otherwise, the value of the second operand will be returned. It is equivalent to the {{Function|Utility|util:or}} function:
<pre class="brush:xquery">
(: if/then/else :)
if (exists($number)) then $number else 0,
(: function call :)
util:or($number, 0),
(: elvis operator :)
$number ?: 0
)
</pre>
 
The behavior of the operator is equivalent to the {{Function|Utility|util:or}} function.
==If Without Else==
</pre>
In general, if you have multiple of or nested if expressions, additional parentheses can improve the readibility of your code:
<pre class="brush:xquery">
)
</pre>
 
The behavior of the if expression is equivalent to the {{Function|Utility|util:if}} function.
=Functions=
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu