op3n
October 20, 2025, 7:38am
1
Hello everyone, I am new to Julia and this discourse, still learning the syntax, please excuse my novice questions
Please let me preface that I have tried to look up the answer before posting this
Is there a way to chain conditionals? Like,
case = a_very_long_condition
case |= another_very_long_condition
I am aware that the syntax can be done in other ways, like using case1, case2; or case = case || another_very_long_condition
Thank you for your time
Does
case = a || b || c || ….
fit your purposes, where a, b, c,… are conditions?
TimG
October 20, 2025, 8:54am
3
Yes, this is possible.
julia> case = false
false
julia> case |= false
false
julia> case |= true
true
julia> case |= false
true
julia> case = true
true
julia> case &= true
true
julia> case &= false
false
julia> case &= true
false
op3n
October 20, 2025, 10:44am
4
Thank you @TimG i tried it and it threw an error, i will retry the syntax
eldee
October 22, 2025, 3:29pm
5
Though note that x |= y is equivalent to x = x | y, not x = x || y. In particular there is no short-circuiting:
julia> x = true;
julia> x = x || error()
true
julia> x |= error()
ERROR:
Stacktrace:
[1] error()
@ Base .\error.jl:44
[2] top-level scope
@ REPL[3]:1
1 Like