Content deleted Content added
m Dating maintenance tags: {{Mergefrom}} |
→top: {{mergefrom}}: discuss=Talk:Conditional operator#Related Article |
||
Line 2:
{{Redirect|?:|use as a binary operator|Elvis operator}}
{{mergefrom|conditional operator|discuss=Talk:Conditional operator#Related Article|date=February 2025}}
In [[computer programming]], the '''ternary conditional operator''' is a [[ternary operator]] that is part of the syntax for basic [[conditional (programming)|conditional expressions]] in several [[programming language]]s. It is commonly referred to as the '''conditional operator''', '''conditional expression''', '''ternary if''', or '''inline if''' (abbreviated '''iif'''). An expression {{code|if a then b else c}} or {{code|a ? b : c}} evaluates to {{code|b}} if the value of {{code|a}} is true, and otherwise to {{code|c}}. One can read it aloud as "if a then b otherwise c". The form {{code|a ? b : c}} is the most common, but alternative syntax do exist; for example, [[Raku (programming language)|Raku]] uses the syntax {{code|a ?? b !! c}} to avoid confusion with the infix operators {{code|?}} and {{code|!}}, whereas in [[Visual Basic .NET]], it instead takes the form {{code|If(a, b, c)}}.
|