# Weird applicable behavior

**URL:** <https://discourse.julialang.org/t/weird-applicable-behavior/66679>\
**Category:** General Usage\
**Created:** [August 19, 2021, 3:30pm UTC](https://discourse.julialang.org/t/weird-applicable-behavior/66679 "2021-08-19T15:30:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bardo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bardo/32/21601_2.png) [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Post date:** [August 19, 2021, 3:30pm UTC](https://discourse.julialang.org/t/weird-applicable-behavior/66679/1 "2021-08-19T15:30:47Z")

</div>

```julia
mutable struct Coords
    x::Float64
    y::Float64
    z::Float64
end
Coords() = Coords(rand(), rand(), rand())

v = Coords()
println(v)
println(applicable(first, v))
println(first(v))

```

yields an (expected) error after passing (wrongly) the applicable test. What is wrong?

```julia
Coords(0.8974851346762911, 0.17094986513890453, 0.9623104755087182)
true
ERROR: LoadError: MethodError: no method matching iterate(::Coords)
```

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [August 19, 2021, 3:32pm UTC](https://discourse.julialang.org/t/weird-applicable-behavior/66679/2 "2021-08-19T15:32:52Z")

</div>

`applicable` just checks if there is a type restriction preventing the function from running. It doesn’t check the full stack of everything that function calls.

```julia

julia> f(x) = g(x);

julia> g(x::Int) = 1;

julia> applicable(f, 1.0)
true

```

---

<div class="post-metadata">

**Author:** ![Bardo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bardo/32/21601_2.png) [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Post date:** [August 19, 2021, 3:36pm UTC](https://discourse.julialang.org/t/weird-applicable-behavior/66679/3 "2021-08-19T15:36:21Z")

</div>

Alas!
