# Inequality operator

**URL:** <https://discourse.julialang.org/t/inequality-operator/72232>\
**Category:** General Usage\
**Created:** [November 29, 2021, 2:18pm UTC](https://discourse.julialang.org/t/inequality-operator/72232 "2021-11-29T14:18:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pjgorski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pjgorski/32/4802_2.png) [@pjgorski](https://discourse.julialang.org/u/pjgorski)\
**Post date:** [November 29, 2021, 2:18pm UTC](https://discourse.julialang.org/t/inequality-operator/72232/1 "2021-11-29T14:18:35Z")

</div>

Why is there the difference between `!=` and `!==` operators?

Examples:

```julia
julia> a = Any["D", "A", "s", "t"]
julia> filter(e->e!="s",a)
3-element Array{Any,1}:
 "D"
 "A"
 "t"
julia> filter(e->e !== "s",a)
4-element Array{Any,1}:
 "D"
 "A"
 "s"
 "t"

```

---

<div class="post-metadata">

**Author:** ![MarcMush](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marcmush/32/18006_2.png) [@MarcMush](https://discourse.julialang.org/u/MarcMush)\
**Post date:** [November 29, 2021, 2:23pm UTC](https://discourse.julialang.org/t/inequality-operator/72232/2 "2021-11-29T14:23:05Z")

</div>

see the [docs for `===`](https://docs.julialang.org/en/v1/base/base/#Core.:===)

`!==` is the negation of `===` and `!=` the negation of `==`

What version of Julia are you using ?

in julia 1.6:

```julia
julia> a = Any["D", "A", "s", "t"]
4-element Vector{Any}:
 "D"
 "A"
 "s"
 "t"

julia> filter(e->e != "s",a)
3-element Vector{Any}:
 "D"
 "A"
 "t"

julia> filter(e->e !== "s",a)
3-element Vector{Any}:
 "D"
 "A"
 "t"

```

---

<div class="post-metadata">

**Author:** ![pjgorski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pjgorski/32/4802_2.png) [@pjgorski](https://discourse.julialang.org/u/pjgorski)\
**Post date:** [November 29, 2021, 2:29pm UTC](https://discourse.julialang.org/t/inequality-operator/72232/3 "2021-11-29T14:29:10Z")

</div>

Cheers!

LTS, of course 😛

(I’m smiling, because a while ago, I was told here, that it’s better not to stick to LTS)

---

<div class="post-metadata">

**Author:** ![MarcMush](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marcmush/32/18006_2.png) [@MarcMush](https://discourse.julialang.org/u/MarcMush)\
**Post date:** [November 29, 2021, 2:45pm UTC](https://discourse.julialang.org/t/inequality-operator/72232/4 "2021-11-29T14:45:20Z")

</div>

This is for sure a weird bug

```julia
julia> versioninfo()
Julia Version 1.0.5
Commit 3af96bcefc (2019-09-09 19:06 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, skylake)

julia> a = ["D", "A", "s", "t"];

julia> filter(e->e !== "s", a)
3-element Array{String,1}:
 "D"
 "A"
 "t"

julia> filter(e->e !== "s", Any[a;])
4-element Array{Any,1}:
 "D"
 "A"
 "s"
 "t"

```

the compiler (?) probably thinks that since they are not the same type, they can’t be `===`

---

<div class="post-metadata">

**Author:** ![pjgorski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pjgorski/32/4802_2.png) [@pjgorski](https://discourse.julialang.org/u/pjgorski)\
**Post date:** [November 29, 2021, 2:57pm UTC](https://discourse.julialang.org/t/inequality-operator/72232/5 "2021-11-29T14:57:15Z")

</div>

I get the same results as you do. The example above was taken from SO post related to `filter`.

```julia
Julia Version 1.0.5
Commit 3af96bcefc (2019-09-09 19:06 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, skylake)

```

But in my code I had a string array, so it should have been working. But I didn’t use a string constant, but a string parsed from the symbol.

```julia
julia> a = ["D", "A", "s", "t"];
julia> ss = :s;
julia> filter(e->e !== string(ss),a)
4-element Array{String,1}:
 "D"
 "A"
 "s"
 "t"
julia> filter(e->e != string(ss),a)
3-element Array{String,1}:
 "D"
 "A"
 "t"

```
