How can this be true?
0 <= 14 < 10
I need to evaluate that a number is in between 0 and 10.
But this breaks my logic.
Shouldn't that expression be false?
This expression:
0 <= 14 < 10
is the same as
(0 <= 14) < 10
which is
1 < 10
true.
What you can do instead is:
if (0 <= x && x < 10) { ...
Python is the only programming language I can think of right now where the expression x < y < z does what you expect it to do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With