# How can kwargs be used in multiple dispatch

**URL:** <https://discourse.julialang.org/t/how-can-kwargs-be-used-in-multiple-dispatch/86790>\
**Category:** General Usage\
**Tags:** question\
**Created:** [September 5, 2022, 9:05am UTC](https://discourse.julialang.org/t/how-can-kwargs-be-used-in-multiple-dispatch/86790 "2022-09-05T09:05:12Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [September 5, 2022, 9:24am UTC](https://discourse.julialang.org/t/how-can-kwargs-be-used-in-multiple-dispatch/86790/2 "2022-09-05T09:24:06Z")

</div>

Kwargs do not differentiate methods, so the Int version was overwritten (note the `1 method` after the second definition).

I use this approach, in cases like this:

```julia
_f(a, b::Int) = 1
_f(a, c::Real) = 2
function f(a; b = nothing, c = nothing)
    !isnothing(b) && return _f(a,b)
    !isnothing(c) && return _f(a,c)
end

```

But I’m not a fan of it. Other opinions are welcome.

---

_[View the full topic](https://discourse.julialang.org/t/how-can-kwargs-be-used-in-multiple-dispatch/86790)._
