Hi,
Quick question: for x= [1, 2, 3]
, why is that
julia> x == 1:3
false
but
julia> x == collect(1:3)
true
?
This is on
Julia Version 0.5.1-pre+33
Commit 20d401c (2017-01-29 21:00 UTC)
Platform Info:
System: Darwin (x86_64-apple-darwin15.6.0)
CPU: Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
WORD_SIZE: 64
BLAS: libgfortblas
LAPACK: liblapack
LIBM: libopenlibm
LLVM: libLLVM-3.7.1 (ORCJIT, haswell)
Doing @edit x == 1:3
results in this call in abstractarray.jl
function (==)(A::AbstractArray, B::AbstractArray)
if indices(A) != indices(B)
return false
end
if isa(A,Range) != isa(B,Range)
return false
end
for (a, b) in zip(A, B)
if !(a == b)
return false
end
end
return true
end
Now we have that
indices(x) == indices(1:3)
but
isa(x,Range) != isa(1:3,Range)```
returns `true` and so
```x == 1:3```
has to be false.
Why has this decision been made?
Thanks!
Davide