0

Ternary operator

could anyone tell me what a ternary oporator is, thank you

22nd Jun 2018, 10:54 AM
Bradley
2 odpowiedzi
+ 1
A ternary operator is a type of operator which needs 3 operands to Operate . Like Unary operator which trigger computation on one operand and like Binary operator which needs 2 operands to Operate .. Ternary operator needs 3 operands to Operate. Ex - ?: -> conditional operator operand1 ? operand2 : operand3
22nd Jun 2018, 10:59 AM
Aveek Bhattacharyya
Aveek Bhattacharyya - avatar
0
Basically, it is like a simple if-else situation, abbreviated. int x; if(2>1) x = 5; else x = 3; This translates to: int x; x = 2>1? 5: 3;
11th Sep 2019, 5:36 AM
A Darren Cruz
A Darren Cruz - avatar