# Distributed Or , julia logicals operators

**URL:** <https://discourse.julialang.org/t/distributed-or-julia-logicals-operators/50698>\
**Category:** Performance\
**Tags:** question, syntax\
**Created:** [November 24, 2020, 5:03pm UTC](https://discourse.julialang.org/t/distributed-or-julia-logicals-operators/50698 "2020-11-24T17:03:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rapasite](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rapasite/32/3719_2.png) [@rapasite](https://discourse.julialang.org/u/rapasite)\
**Post date:** [November 24, 2020, 5:03pm UTC](https://discourse.julialang.org/t/distributed-or-julia-logicals-operators/50698/1 "2020-11-24T17:03:25Z")

</div>

I asked a question on [https://julialang.org/slack/](https://julialang.org/slack/).

Question was:

- Is there any way to write something like `x == (4 | 5)` witch return `true` if `x == 4` or if `x == 5`?

The regular **answer** is:

- `x in (4,5)` or any other way to write this ex: `x ∈ (4,5)`, `x ∈ (4 ∪ 5)`

Although if you wanna still use the operator `|`, @Mason propose this solution:

```julia
struct DistributedOr{L, R}
    l::L
    r::R
end

Base.:(==)(x, o::DistributedOr) = x == o.l || x == o.r

```

test:

```julia
let x = 4, | = DistributedOr
    x == (4 | 5)
end

```

`true`

@Sukera (I think) suggested another implementation:

```julia
struct OR{T}
        els::T
        OR(args...) = new{typeof(args)}(args)
end

Base.:(==)(a,b::OR) = any((a,) .== b.els)

```

test:

```julia
let x = 7, | = OR
    x == (5 | 6 | 7 | 8)
end

```

`true`
