# Testing whether value is (or not) in array

**URL:** <https://discourse.julialang.org/t/testing-whether-value-is-or-not-in-array/37995>\
**Category:** General Usage\
**Tags:** question\
**Created:** [April 21, 2020, 10:47pm UTC](https://discourse.julialang.org/t/testing-whether-value-is-or-not-in-array/37995 "2020-04-21T22:47:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![EricChameroy](https://avatars.discourse-cdn.com/v4/letter/e/7ab992/32.png) [@EricChameroy](https://discourse.julialang.org/u/EricChameroy)\
**Post date:** [April 21, 2020, 10:47pm UTC](https://discourse.julialang.org/t/testing-whether-value-is-or-not-in-array/37995/1 "2020-04-21T22:47:32Z")

</div>

Hi everyone,

I understand that if I want to test if a given value is present in an array, I can use:

_value_ in _array_

However, how do I go about testing if a given value is not in an array? So far, the only solution I could come up with is:

!(_value_ in _array_)

Is there anything similar to using “not in” as in Python?

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [April 22, 2020, 12:09am UTC](https://discourse.julialang.org/t/testing-whether-value-is-or-not-in-array/37995/2 "2020-04-22T00:09:40Z")

</div>

There is `∉`, which you can get by typing `\notin<tab>`. There doesn’t seem to be an ascii equivalent.

---

<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:** [April 22, 2020, 5:47am UTC](https://discourse.julialang.org/t/testing-whether-value-is-or-not-in-array/37995/3 "2020-04-22T05:47:10Z")

</div>

> [@EricChameroy](#):
>
> So far, the only solution I could come up with is:
> 
> `!( *value* in *array* )`

While this particular one has a Unicode shorthand as pointed out by @pdeffebach, generally it is not good design to introduce two functions for `predicate(args...)` and `!predicate(args...)` — that’s why we have `!`. So `!(a in b)` is fine.

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [April 22, 2020, 6:19am UTC](https://discourse.julialang.org/t/testing-whether-value-is-or-not-in-array/37995/4 "2020-04-22T06:19:17Z")

</div>

There’s an issue with some discussion here: [! for infix operators · Issue #25512 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/25512)

---

<div class="post-metadata">

**Author:** ![EricChameroy](https://avatars.discourse-cdn.com/v4/letter/e/7ab992/32.png) [@EricChameroy](https://discourse.julialang.org/u/EricChameroy)\
**Post date:** [April 23, 2020, 1:30am UTC](https://discourse.julialang.org/t/testing-whether-value-is-or-not-in-array/37995/5 "2020-04-23T01:30:46Z")

</div>

Thanks for the replies everyone. And thanks for the link to the discussion thread DNF. I was driving myself crazy thinking there was already a clear way to do this and I just couldn’t find it documented anywhere.

I take it that this is still an ongoing topic?
