I was trying to write a small program in Ruby, and I ran into the following problem: Ruby doesn't seem to be able to group numbers in parentheses.
For example:
puts (2 - 0) / 10
# prints out 0
There is obviously a flaw in the logic here. What should be happening is that (2 - 0)
gets evaluated first (according to the order of operations) and then (2 - 0)
should get divided by 10
.
Does grouping with parentheses in Ruby not work? By the way, I'm using 2.1.2.