# How to match at least one type in vararg list for method?

**URL:** https://discourse.julialang.org/t/how-to-match-at-least-one-type-in-vararg-list-for-method/4087
**Category:** General Usage
**Tags:** question
**Created:** [June 5, 2017, 4:07am UTC](https://discourse.julialang.org/t/how-to-match-at-least-one-type-in-vararg-list-for-method/4087 "2017-06-05T04:07:28Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)
#### Post date: [June 5, 2017, 4:07am UTC](https://discourse.julialang.org/t/how-to-match-at-least-one-type-in-vararg-list-for-method/4087/1 "2017-06-05T04:07:28Z")

</div>

Let’s say for example, you have:

```julia
Base.min(ex::Sym, exs...) = 
    reduce((x,y)->sympy_meth(:Min, x, y), ex, exs)

```

This will not catch anything where the `Sym` comes in the `exs` array.

For example,

- `Base.min(Sym(x), 123)` -------- works
- `Base.min(404, Sym(x))` -------- does not work!

Is there a way to to say `exs` is treated as `Sym` if at least one is present?

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [June 5, 2017, 7:51am UTC](https://discourse.julialang.org/t/how-to-match-at-least-one-type-in-vararg-list-for-method/4087/2 "2017-06-05T07:51:11Z")

</div>

AFAIK there is no way to do this directly. For the best approach, see the family of helper functions for `broadcast`. In particular, depending on what you want exactly (which you did not describe fully), you need roughly something like

```julia
_mymin(T, exs...) = ...
mymin(exs...) = _mymin(calculateT(exs...), exs...)

```

where `T` is the result of some computation on types from the types of `exs`, done by a helper function (look at `containertype`, `_containertype`, and `promote_containertype`, obviously you need something much simpler).

---

<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: [June 5, 2017, 11:03am UTC](https://discourse.julialang.org/t/how-to-match-at-least-one-type-in-vararg-list-for-method/4087/3 "2017-06-05T11:03:35Z")

</div>

There’s a trick that achieves this result in StaticArrays, but AFAIK it’s not something that Julia guarantees: [https://github.com/JuliaArrays/StaticArrays.jl/pull/136#discussion\_r109543567](https://github.com/JuliaArrays/StaticArrays.jl/pull/136#discussion_r109543567)

---

<div class="post-metadata">

### Author: ![jameson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jameson/32/23_2.png) [@jameson](https://discourse.julialang.org/u/jameson)
#### Post date: [June 7, 2017, 9:41pm UTC](https://discourse.julialang.org/t/how-to-match-at-least-one-type-in-vararg-list-for-method/4087/4 "2017-06-07T21:41:56Z")

</div>

Yes, the plan is to probably change that in the next release ([https://github.com/JuliaLang/julia/issues/21026#issuecomment-306624369](https://github.com/JuliaLang/julia/issues/21026#issuecomment-306624369))
