# Future-proof elementwise array comparison

**URL:** <https://discourse.julialang.org/t/future-proof-elementwise-array-comparison/11181>\
**Category:** General Usage\
**Tags:** question\
**Created:** [May 27, 2018, 12:46pm UTC](https://discourse.julialang.org/t/future-proof-elementwise-array-comparison/11181 "2018-05-27T12:46:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [May 27, 2018, 12:46pm UTC](https://discourse.julialang.org/t/future-proof-elementwise-array-comparison/11181/1 "2018-05-27T12:46:09Z")

</div>

In `v0.7`, thanks to [#16401](https://github.com/JuliaLang/julia/pull/16401),

```julia
julia> [1, 2, 3] == 1:3
true

```

but in `v0.6.2` it is `false`. I am currently writing unit tests that make a lot of these comparisons, and I want it to work in both versions. Should I use `all(a .== b)` or something similar, or is there a smooth transition using `Compat.jl`?

---

<div class="post-metadata">

**Author:** ![nalimilan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nalimilan/32/147_2.png) [@nalimilan](https://discourse.julialang.org/u/nalimilan)\
**Post date:** [May 28, 2018, 8:35pm UTC](https://discourse.julialang.org/t/future-proof-elementwise-array-comparison/11181/2 "2018-05-28T20:35:24Z")

</div>

I don’t think Compat can easily provide a solution which will work everywhere. You’d have to use `@compat` and replace the call to `==` with a custom operator. What packages have been doing until 0.7 is `== collect(1:3)`, which is stricter than using `all` since it also checks the shape.
