In Unix shell scripts, we can do the following
❯ [[ -n $HOME ]] && echo "true statement" || echo "else statement"
true statement
❯ [[ -n $NOT_A_ENV ]] && echo "true statement" || echo "else statement"
else statement
However, it does not work in Julia
julia> true && println("true statement") || println("else statement")
true statement
ERROR: TypeError: non-boolean (Nothing) used in boolean context
Stacktrace:
[1] top-level scope
@ REPL[15]:1
Is there a similar feature in Julia (in one line, of course)?
PS: I put short-circuit evaluation in the title as I suppose it were possible, but solution with other approaches is welcome as well