shift(x) = ifelse(x > 10, x + 1, x - 1)
Usage:
julia> shift(10)
9
julia> shift(11)
12
julia> shift(-1)
-2
The ifelse
function will evaluate both branches, even the one that is not selected. This can be useful either when the branches have side effects that must be evaluated, or because it can be faster if both branches themselves are cheap.