Also known as the Conditional Operator.
This is the short form of the if-else condition.
If the condition evaluates to true then it will execute the first statement after ?, otherwise the second statement after : will be executed.
if (bValue == true) ? sVariable1 = "text" sVariable2 = "text";
Nested ternary operators are possible by including a conditional expression as a second statement.
The ternary operator is right-associative.
The expression a ? b : c ? d : e is evaluated as a ? b : (c ? d : e) and not evaluated as (a ? b : c) ? d : e.
© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext