Holla Tech - Learn

Operator Precedence
 

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.
For example: 

x = (3+2) * 4
puts x
# outputs 20 

 

TASK:
Copy and paste the line of codes into your text editor to play around with the outputs. 

BACK NEXT

CLICK ON THE BUTTON BELOW TO GO TO THE RUBY MAIN COURSE PAGE. 

RUBY MAIN COURSE PAGE

 


© License: All Rights Reserved 


CONTACT HOLLA TECH – LEARN SUPPORT