December 2018
Beginner to intermediate
500 pages
12h 10m
English
Sometimes short-circuit expressions can confuse the compiler, resulting in errors or unexpected results. For example, short-circuit expressions are often used with assignment operations, as follows:
julia> x > 15 || message = "That's a lot"
This will fail with the syntax: invalid assignment location "(x > 15) || message" error because the = assignment operator has higher precedence than logical or and ||. It can easily be fixed by using brackets to explicitly control the evaluation order:
julia> x > 15 || (message = "That's a lot") "That's a lot"
It's something to keep in mind as it's a common source of errors for beginners.
Read now
Unlock full access