Ternary Operation

In mathematics, a ternary operation is any operation of arity three, that is, that takes three arguments. A ternary operator (sometimes inaccurately referred to as a tertiary operator) is an operator that takes three arguments. A common form found in many programming languages is an operator that is used as shorthand for if-then-else statements. The general form is condition ? op1 : op2. If condition is true, the statement evaluates as op1; otherwise, it evaluates as op2. In programming, especially in the C programming language, the "" operator is a ternary operator. It takes in a boolean value, and two statements, and returns the return value of the first statement if the boolean value is true, and the return value of the second statement if the boolean value is false. For example, z = (x > y) ? x : y; assigns x to z if x is greater than y, and otherwise assigns y to z (the statement sets z equal to the maximum of x and y). Some programmers regard using this ternary operator as bad practice, though it can be useful in certain circumstances to avoid excessive if statements.

 

<< PreviousWord BrowserNext >>
han bennink
flag of the british virgin islands
flag of the united states virgin islands
flag of zambia
deccan
okonek
wallingford, pennsylvania
seek truth from facts
farm aid
lipka
yuan shao
list of indian americans
komrom
tarnwka
baron dacre
hazen argue
yan liang
zakrzewo
ryokan inn
xun yu
sugar pine
edward charles pickering
wen chou
leicester abbey
chunyu qiong
earth minbari war
head up display
boleslaw domanski
rossby number
baron dudley
xu shu
alan yentob
sierra san pedro mrtir
member of provincial parliament
blue ensign
william kelly, sr. (politician)
han sui
castell coch
common operator notation
sparta zlotw
lu su
guo jia
baron dormer
comprehensive employment and training act