3 ms·
There is quite a lot to criticize Solidity but this is quite a bad example. Operator precedence is often different between languages. And because some language
by bhaak 9y ago
There is quite a lot to criticize Solidity but this is quite a bad example. Operator precedence is often different between languages.
And because some languages miss a boolean type, you can't deduce if 1 was because of the bitwise or operator or the less-than operator.
Let's take a look at (2 | 0 < 1) instead.
C and JavaScript result in 3.
Ruby and Python return False.
Java throws a compilation error: error: bad operand types for binary operator '|'. first type: int, second type: boolean
Now which of these behaviours is the one that is the universal right one? (Hint: no one, you should always know the rules of the language you program in or if you don't, just throw in some parentheses to be on the safe side)