Course of Raku / Advanced / Operators / Review of operator behaviour / Exercises / Force the order
Solution: Force the order
Here is a possible solution to the task.
Code
say 2 ** (3 + 1);🦋 You can find the source code in the file force-the-order.raku.
Output
16Comments
Without the parentheses,
**would bind tighter than+, giving(2 ** 3) + 1 = 9.The parentheses raise the precedence of the addition, so
3 + 1is computed first and the expression becomes2 ** 4, which is16. Parentheses always let you override the default precedence.
Course navigation
← Force the order | Power tower →