Chaining conditionals

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?

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

Thank you @TimG i tried it and it threw an error, i will retry the syntax

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