Quick simple example of the problem I'm running into. Is there something I'm missi

Quick simple example of the problem I’m running into. Is there something I’m missing on how to do this? I have more than 2 conditions for my thing and I want a bit array returned based on different arrays.

julia> [1.0, 1.5] .<= 2 && [2.0, 2.5] .<= 3
ERROR: TypeError: non-boolean (BitArray{1}) used in boolean context
Stacktrace:
 [1] top-level scope at REPL[25]:1

Note that the original poster on Slack cannot see your response here on Discourse. Consider transcribing the appropriate answer back to Slack, or pinging the poster here on Discourse so they can follow this thread.
(Original message :slack:) (More Info)

You probably want bitwise with broadcasting:

julia> ([1.0,1.5] .<= 2) .& ([2.0,2.5] .<= 3)
2-element BitArray{1}:
 1
 1

The error message says your operands are BitArrays (bitwise arrays), and “boolean context” refers to && which operates on booleans not bits. Bitwise means you should use &, and array means you should broadcast with ..

The error messages can be confusing, but they can often be decoded. If you do ? && or ? & in REPL, the docstrings say boolean and bitwise, respectively.

1 Like