I hava read from Khalid Mugal and others that the conditional operator is right associative.
Can someone explain to me what this means and show me a simple example?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Conditional Operator ?: is right associative because right side evaluates first
Explaniation
A simple expression of conditional operator is
and an example is
in any case either true or false, its evaluate/calculate values on right side first then returns value according to condition
Further Explaination:
It is syntactically right-associative (it groups right-to-left), so that a?b:c?d:e?f:g means the same as a?b:(c?d:(e?f:g)).
Also consider Wiki defination
“The associativity (or fixity) of an operator is a property that determines how operators of the same precedence are grouped in the absence of parentheses.”
Hopes that helps