PCEP-30-02 · Question #109
Right-sided binding means that the following expression `` 1 1 2 3 `` will be evaluated:
The correct answer is A. from right to left. Right-sided binding (right associativity) means the ` operator chains from right to left, so 1 2 3 is evaluated as 1 (2 3) - the rightmost operation executes first, making option A correct. Option B is wrong because operator evaluation in programming languages follows…
Question
1 1 ** 2 ** 3
will be evaluated:Options
- Afrom right to left
- Bin random order
- Cfrom left to right
How the community answered
(26 responses)- A81% (21)
- B12% (3)
- C8% (2)
Explanation
Right-sided binding (right associativity) means the ** operator chains from right to left, so 1 ** 2 ** 3 is evaluated as 1 ** (2 ** 3) - the rightmost operation executes first, making option A correct. Option B is wrong because operator evaluation in programming languages follows deterministic rules defined by the language specification, never random order. Option C is wrong because left-to-right would produce (1 ** 2) ** 3, which changes the result - for example, 2 ** 3 ** 2 gives 512 with right associativity but only 64 left-to-right. A handy memory trick: think of the word "right" in "right-sided" as both the direction (right to left) and the correct way the exponent tower collapses - just like in math, 2^{3^2} means you resolve the top of the tower first.
Community Discussion
No community discussion yet for this question.