Ternary operation

From Wikipedia, the free encyclopedia
  (Redirected from Ternary operator)
Jump to navigation Jump to search

In mathematics, a ternary operation is an n-ary operation with n = 3. A ternary operation on a set A takes any given three elements of A and combines them to form a single element of A. An example of a ternary operation is the product in a heap.

In computer science, a ternary operator is an operator that takes three arguments.[1] The arguments and result can be of different types. Many programming languages that use C-like syntax[2] feature a ternary operator, ?:, which defines a conditional expression. Since this operator is often the only existing ternary operator in the language, it is sometimes simply referred to as "the ternary operator". In some languages, this operator is referred to as "the conditional operator". Another example for a ternary operator is between, as used in SQL.

See also


  1. ^ MDN, nmve. "Conditional (ternary) Operator". Mozilla Developer Network. MDN. Retrieved 20 February 2017.
  2. ^ Hoffer, Alex. "Ternary Operator". Cprogramming.com. Cprogramming.com. Retrieved 20 February 2017.
Retrieved from "https://en.wikipedia.org/w/index.php?title=Ternary_operation&oldid=863734540"
This content was retrieved from Wikipedia : http://en.wikipedia.org/wiki/Ternary_operator
This page is based on the copyrighted Wikipedia article "Ternary operation"; it is used under the Creative Commons Attribution-ShareAlike 3.0 Unported License (CC-BY-SA). You may redistribute it, verbatim or modified, providing that you comply with the terms of the CC-BY-SA