Guajara in other languages: Spanish, Deutsch, French, Italian ...



Ternary operation

In mathematics, a ternary operation is an operation of arity three, that is, it takes three arguments.

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: (x > 3) ? (y = TOO_BIG) : (y = x); assigns TOO_BIG to y if x is greater than 3, otherwise x is assigned to y.

Some programmers regard using this ternary operator as bad practice, though it can be useful in certain circumstances to avoid excessive if statements.





Wikipedia - All text is available under the terms of the GNU Free Documentation License.

Tagoror dot com  -  Legal Information  -  Contact us