TypeError: non-boolean (BitArray{1}) used in boolean context

Hi, I am a newbie in Julia, using version 1.1.1.

TypeError: non-boolean (BitArray{1}) used in boolean context

What’s wrong with the following code?

x1 = collect(0:0.1:2)
x2a = 1 .-0.5.* x1
x2b = ifelse(2 .-2* x1 .>=0, 2 .- 2* x1,0)

Thanks!

1 Like

This is exactly the same as the answer in MethodError: no method matching -(::Int64, ::Array{Float64,1}) - #3 by aaron.

ifelse works on scalars so if you want to do it elementwise use the dot syntax, ifelse.(...).

2 Likes

Thank you again!