Testing whether value is (or not) in array

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?

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

4 Likes

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.

There’s an issue with some discussion here: ! for infix operators · Issue #25512 · JuliaLang/julia · GitHub

1 Like

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?