I'm using Julia 1.0.3 and I'm attempting to run a line of code that was written in Julia 0.7. This line runs the base ifelse function along an array of boolean values. It appears that in this version of Julia, the ifelse function can no longer be run against a bitarray. Is there a way to get ifelse to work here?
x = collect(0:0.1:2)
x2 = ifelse(2 .- 2*x.>=0, 2 .- 2*x, 0)
I'm expecting to get an array that shows 2-2x for all values of x>=0 and 0 otherwise. I am getting the following error.
TypeError: non-boolean (BitArray{1}) used in boolean context
Stacktrace:
[1] top-level scope at In[67]:1
WARNING: ifelse(c::AbstractArray{Bool}, x::AbstractArray, y) is deprecated, use ifelse.(c, x, y) instead.When updating code, it can be very helpful to walk through each version and fix the deprecation warnings as you go.collect. Just use the range0:0.1:2directly.