# Is there a way I can define custom method on this "function"?

**URL:** <https://discourse.julialang.org/t/is-there-a-way-i-can-define-custom-method-on-this-function/88466>\
**Category:** New to Julia\
**Created:** [October 9, 2022, 4:12am UTC](https://discourse.julialang.org/t/is-there-a-way-i-can-define-custom-method-on-this-function/88466 "2022-10-09T04:12:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brian1/32/49250_2.png) [@Brian1](https://discourse.julialang.org/u/Brian1)\
**Post date:** [October 9, 2022, 4:12am UTC](https://discourse.julialang.org/t/is-there-a-way-i-can-define-custom-method-on-this-function/88466/1 "2022-10-09T04:12:56Z")

</div>

a variable named `a` isa `Missing` or `Float64`. Which type it exactly belongs to would be known until runtime. So if I want to check

```julia
b = 1
a > 1 && b == 1 

```

I have to:

```julia
!ismissing(a) && a > 1 && b == 1

```

So is there a way I can do it like:

```julia
||(::Missing, ::Bool) = false

a = missing

a > 1 && b == 1
false

```

---

<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:** [October 9, 2022, 4:21am UTC](https://discourse.julialang.org/t/is-there-a-way-i-can-define-custom-method-on-this-function/88466/2 "2022-10-09T04:21:57Z")

</div>

> [@Brian1](#):
>
> `||(::Missing, ::Bool) = false`

this is type piracy, please don’t override Julia’s base function on base type

```julia

julia> a ⊗ b = a||b
⊗ (generic function with 1 method)

julia> ⊗(::Missing, ::Bool) = false
⊗ (generic function with 2 methods)

julia> a = missing
missing

julia> (a > 1) ⊗ true
false

```

---

<div class="post-metadata">

**Author:** ![Brian1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brian1/32/49250_2.png) [@Brian1](https://discourse.julialang.org/u/Brian1)\
**Post date:** [October 9, 2022, 5:00am UTC](https://discourse.julialang.org/t/is-there-a-way-i-can-define-custom-method-on-this-function/88466/3 "2022-10-09T05:00:17Z")

</div>

This works crecttly, but can not work like the original `||`:

```julia
a ⊗ b = a||b;

⊗(::Missing, ::Bool) = false

a = missing

true ⊗ (println("function is running"); true)
#true
#function is running"

true || (println("function is running"); true)
#true

```

---

<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:** [October 9, 2022, 5:07am UTC](https://discourse.julialang.org/t/is-there-a-way-i-can-define-custom-method-on-this-function/88466/4 "2022-10-09T05:07:27Z")

</div>

> [@Brian1](#):
>
> ut can not work like the original `||`:

well, you can’t have short circuit behavior on a normal function, that’s why you can’t override `||`, it’s not just a normal function
