# \`hasmethod\` with a "wildcard"

**URL:** https://discourse.julialang.org/t/hasmethod-with-a-wildcard/114578
**Category:** General Usage
**Created:** [May 22, 2024, 2:52pm UTC](https://discourse.julialang.org/t/hasmethod-with-a-wildcard/114578 "2024-05-22T14:52:53Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mrufsvold](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mrufsvold/32/31600_2.png) [@mrufsvold](https://discourse.julialang.org/u/mrufsvold)
#### Post date: [May 22, 2024, 2:52pm UTC](https://discourse.julialang.org/t/hasmethod-with-a-wildcard/114578/1 "2024-05-22T14:52:53Z")

</div>

I’d like to check if a type has `iterate` defined. Of course, `iterate` needs two methods – `iterate(::T)` and `iterate(::T, state)`.

```julia
julia> hasmethod(iterate, (Vector{Int}, Any))
true

julia> hasmethod(iterate, (Tuple{Int}, Any))
false # huh?

julia> hasmethod(iterate, (Tuple{Int}, Int))
true # Oooh...

```

I want to know if there is a two-argument method for `iterate` where the first argument is of some type `T`, but I don’t care what the second type is. I know that I could call `methods(iterate)` and then filter the returned list, but is there some way for me to called `hasmethod(iterate, (Tuple{Int}, *))`?

---

<div class="post-metadata">

### Author: ![screw\_dog](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/screw_dog/32/48119_2.png) [@screw\_dog](https://discourse.julialang.org/u/screw_dog)
#### Post date: [May 22, 2024, 2:57pm UTC](https://discourse.julialang.org/t/hasmethod-with-a-wildcard/114578/2 "2024-05-22T14:57:37Z")

</div>

I think `methods` can be used here:

```julia
methodlist = methods(iterate, (Tuple{Int}, Any))
isempty(methodlist) # false

```

---

<div class="post-metadata">

### Author: ![mrufsvold](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mrufsvold/32/31600_2.png) [@mrufsvold](https://discourse.julialang.org/u/mrufsvold)
#### Post date: [May 22, 2024, 2:58pm UTC](https://discourse.julialang.org/t/hasmethod-with-a-wildcard/114578/3 "2024-05-22T14:58:18Z")

</div>

Ah! Brilliant!
