Ruby evaluates a mathematical expression using an order of operations that is based on operator precedence. Exponentiation has the highest precedence followed by multiplication, division, and modulus from left to right, and then addition and subtraction from left to right.
You can change the order of operations by using parentheses.
x = (3+2) * 4
# outputs 20
CLICK ON THE BUTTON BELOW TO GO TO THE RUBY MAIN COURSE PAGE.
© License: All Rights Reserved
CONTACT HOLLA TECH – LEARN SUPPORT