I read on Wikipedia that there are often only one ternary operation type possible in C-like languages, which is the conditional expression.
I am trying to find out what other ternary operation exists and what language would make use of them.
I read on Wikipedia that there are often only one ternary operation type possible in C-like languages, which is the conditional expression.
I am trying to find out what other ternary operation exists and what language would make use of them.
<expression> for <variable> in <list>
” from python could be considered a ternary operator as well. If you argue that the variable name in there is not an expression, then you could use the “<expresstion> for <variable> in <list> if <condition>
” where expression, list and condition are arbitrary expressions. The specification lists generator expressions in the same section as most operators, but doesn't call it an operator and doesn't list it in the table for operator precedence.In general, many languages have a far less clear line distinguishing operators from functions on the one side or control constructs on the other side. In those cases it is often hard to decide whether some ternary construct is indeed an operator or not.