+ 1
Breaking order of precedence? Ruby
Why does the code puts 4 / 2 * 2 outputs 4 instead of 1? Should'nt it multiply first then divide?
2 Réponses
+ 2
Python or JS evaluate operations with equally ranked operators from left to right (except pow/root); I assume Ruby does the same.
If you want a different behavior you'd need parentheses.
+ 1
Thank you.