Course of Raku / Advanced / Operators / Review of operator behaviour
Quiz — Precedence
What does the following program print?
say 2 * 3 ** 2;| 1 | 18 |
| 0 | 36 |
| 0 | 12 |
| 0 | 81 |
** has higher precedence than *, so the
exponentiation happens first: 3 ** 2 is 9, and
then 2 * 9 is 18. Reading it left to right as
(2 * 3) ** 2 would give the wrong answer,
36.