I have a questions regarding the chained comparisons in Julia. I read this section in the manual but it is still unclear.
In Julia, does this:
if var1 && var2 != 1
mean this (in Python):
if (var1 and var2) != 1:
Thank you!
You can always quote an expression to see how the parser interprets it:
julia> :(var1 && var2 != 1)
:(var1 && (var2!=1))
In this case, the !=
binds more tightly than the &&
. This is standard precedence in languages that have these two operators) such as C and Java.
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