"?:" redirects here. For use as a binary operator, see Elvis operator.
In computer programming, the ternary conditional operator is a ternary operator that is part of the syntax for basic conditional expressions in several programming languages. It is commonly referred to as the conditional operator, ternary if, or inline if (abbreviated iif). An expression a ? b : c evaluates to b if the value of a is true, and otherwise to c. One can read it aloud as "if a then b otherwise c". The form a ? b : c is by far and large the most common, but alternative syntaxes do exist; for example, Raku uses the syntax a ?? b !! c to avoid confusion with the infix operators ? and !, whereas in Visual Basic .NET, it instead takes the form If(a, b, c).
It originally comes from CPL, in which equivalent syntax for e1 ? e2 : e3 was e1 → e2, e3.[1][2]
Although many ternary operators are possible, the conditional operator is so common, and other ternary operators so rare, that the conditional operator is commonly referred to as the ternary operator.
^Strachey, Christopher (2000). "Fundamental Concepts in Programming Languages". Higher-Order and Symbolic Computation. 13: 11–49. doi:10.1023/A:1010000313106. S2CID 14124601.
^"5.5 Conditional expressions". The BCPL Reference Manual(PDF). 1967. pp. 16–17. Archived from the original (PDF) on 2016-03-16. Retrieved 2017-03-15.
and 18 Related for: Ternary conditional operator information
computer programming, the ternaryconditionaloperator is a ternaryoperator that is part of the syntax for basic conditional expressions in several programming...
Majority function Ternaryconditionaloperator for a list of ternaryoperators in computer programming languages Ternary Exclusive or Ternary equivalence relation...
programming languages, ?: is called the conditionaloperator. It is a type of ternaryoperator. However, ternaryoperator in most situations refers specifically...
computer science Ternary Golay code, a perfect [11, 6, 5] ternary linear code ?:, a ternaryconditionaloperator used for basic conditional expressions in...
contrast to the ternaryconditional if operator used as x ? x : y, but like the binary Elvis operator used as x ?: y, the null coalescing operator is a binary...
(including C++, C#, Java, Julia, Perl, and others) provide the ternaryconditionaloperator ?:. The first operand (the condition) is evaluated, and if it...
} Since PHP 5.3 supports Elvis operator (?:) in which it is possible to omit the middle part of the ternaryoperator. $c = $a ?: $b; /* Equivalent to...
languages, string concatenation is a binary infix operator, and in some it is written without an operator. This is implemented in different ways: Overloading...
the values from the two adjacent cells Statistical multiplexer Ternaryconditionaloperator Dean, Tamara (2010). Network+ Guide to Networks. Delmar. pp. 82–85...
access q. Between the evaluation of the first operand of the ternaryconditionaloperator and its second or third operand. For example, in the expression...
notable that ALGOL's conditional expression in the form z := if a > b then a else b; has an equivalent in C (the ternaryoperator from CPL) but not in...
boolean operators have been lifted to support ternary logic thus keeping impedance with SQL. The Java boolean operators do not support ternary logic, nor...
other authors (like NIST) apply this notational simplification only conditionally in conjunction with specific multi-character function names (like sin)...
to as an operator. In two-valued logic there are 2 nullary operators (constants), 4 unary operators, 16 binary operators, 256 ternaryoperators, and 2 2...