# If in === ∈, why does .∈ work but .in fails with a ParseError?

**URL:** <https://discourse.julialang.org/t/if-in-why-does-work-but-in-fails-with-a-parseerror/125464>\
**Category:** General Usage\
**Tags:** syntax, broadcasting, dataframesmeta, operator\
**Created:** [February 1, 2025, 10:24pm UTC](https://discourse.julialang.org/t/if-in-why-does-work-but-in-fails-with-a-parseerror/125464 "2025-02-01T22:24:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matheus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/matheus/32/206186_2.png) [@Matheus](https://discourse.julialang.org/u/Matheus)\
**Post date:** [February 1, 2025, 10:24pm UTC](https://discourse.julialang.org/t/if-in-why-does-work-but-in-fails-with-a-parseerror/125464/1 "2025-02-01T22:24:33Z")

</div>

Hello everyone,

I’m trying to understand the following behavior regarding `in` and `∈` (I guess they’re called `operators`?). While they are **functionally identical** (`in === ∈` returns `true`), they behave differently when used with broadcasting (`.`) inside macros like `@subset` in `DataFramesMeta.jl`. Here’s the code:

```julia
using DataFrames, DataFramesMeta

df = DataFrame(x = [1, 1, 2, 2], y = [1, 2, 101, 102])

# This works as expected:
@subset df :y .∈ Ref([101, 102])

# This fails with a ParseError:
@subset df :y .in Ref([101, 102])

```

ParseError: whitespace is not allowed here.

Why is that?

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [February 1, 2025, 10:59pm UTC](https://discourse.julialang.org/t/if-in-why-does-work-but-in-fails-with-a-parseerror/125464/2 "2025-02-01T22:59:38Z")

</div>

> [@Matheus](#):
>
> Why is that?

because parser treats them differently. It may sound like a non-answer but that’s basically the whole reason. The parser COULD special-case `.in`, but that would be more confusing / inconsistent than helpful

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [February 2, 2025, 12:14am UTC](https://discourse.julialang.org/t/if-in-why-does-work-but-in-fails-with-a-parseerror/125464/3 "2025-02-02T00:14:03Z")

</div>

This is it. The object bound to the names `in` and `∈` are the same function object (and this `===` but that doesn’t have any bearing on how they’re parsed. One is a name, the other is an operator. You can also easily change what they are bound to do that they don’t refer to the same object.

---

<div class="post-metadata">

**Author:** ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Post date:** [February 2, 2025, 6:59am UTC](https://discourse.julialang.org/t/if-in-why-does-work-but-in-fails-with-a-parseerror/125464/4 "2025-02-02T06:59:55Z")

</div>

Of course it’s implicit in the previous answers - and even in the question, but I think it is worth telling, for other readers at least, that broadcasting does work with `in`, but it should be coded as for regular functions, i.e. `in.(y, Ref([101, 102]))` - or in the OP’s example with DataFramesMeta:

```julia
@subset df in.(:y, Ref([101, 102]))

```

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [February 2, 2025, 12:59pm UTC](https://discourse.julialang.org/t/if-in-why-does-work-but-in-fails-with-a-parseerror/125464/5 "2025-02-02T12:59:10Z")

</div>

Another thing implicit in previous answers, but perhaps should be made explicit, is that whether `in === ∈` is true depends on the namespace, that is, they’re identical in `Main`, but not in all other modules:

```julia-repl
julia> in === ∈
true

julia> baremodule MyModule
           const in = 3
           const ∈ = 7
           const v = in === ∈
       end
Main.MyModule

julia> MyModule.in === MyModule.:(∈)
false

julia> MyModule.v
false

```

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [February 2, 2025, 1:02pm UTC](https://discourse.julialang.org/t/if-in-why-does-work-but-in-fails-with-a-parseerror/125464/6 "2025-02-02T13:02:59Z")

</div>

> [@StefanKarpinski](#):
>
> One is a name, the other is an operator.

To elaborate on this:

- `in` is just a name
- `∈` is an operator, meaning it’s possible to call it, for example, like so: `x ∈ y`, and the broadcasting syntax is different
