# Question about the selection mechanism of multiple dispatch

**URL:** <https://discourse.julialang.org/t/question-about-the-selection-mechanism-of-multiple-dispatch/11175>\
**Category:** General Usage\
**Created:** [May 27, 2018, 2:22am UTC](https://discourse.julialang.org/t/question-about-the-selection-mechanism-of-multiple-dispatch/11175 "2018-05-27T02:22:53Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [May 27, 2018, 9:11pm UTC](https://discourse.julialang.org/t/question-about-the-selection-mechanism-of-multiple-dispatch/11175/4 "2018-05-27T21:11:24Z")

</div>

Yes. A type `T` is always more specific than `Union{T, X}` for some other type `X`, so a method defined with `::T` as its argument will be more specific than one with `::Union{T, X}` (assuming no change in the other arguments).

A few examples:

- `foo(::T)` is more specific than `foo(::Union{T, X})`
- `foo(::T, ::X)` is more specific than `foo(::Union{T, X}, ::X)`
- `foo(::T, ::X)` is more specific than `foo(::T, ::Union{T, X})`
- `foo(::T, ::X)` is more specific than `foo(::Union{T, X}, ::Union{T, X})`

But there are ambiguous cases:

- `foo(::Union{T, X}, ::X)` is ambiguous with (neither more nor less specific than) `foo(::T, ::Union{T, X})`

If there is no unique most-specific method, then Julia will throw an ambiguity error, so there’s no need to worry about one method being arbitrarily preferred.

---

_[View the full topic](https://discourse.julialang.org/t/question-about-the-selection-mechanism-of-multiple-dispatch/11175)._
