# function vs. getfield

**URL:** <https://discourse.julialang.org/t/function-vs-getfield/17418>\
**Category:** General Usage\
**Created:** [November 12, 2018, 2:59am UTC](https://discourse.julialang.org/t/function-vs-getfield/17418 "2018-11-12T02:59:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![unhandyandy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/unhandyandy/32/7634_2.png) [@unhandyandy](https://discourse.julialang.org/u/unhandyandy)\
**Post date:** [November 12, 2018, 2:59am UTC](https://discourse.julialang.org/t/function-vs-getfield/17418/1 "2018-11-12T02:59:17Z")

</div>

Why doesn’t typeof return “function”?

```julia
julia> testint
#104 (generic function with 1 method)

julia> typeof(testint)
getfield(Main, Symbol("##104#113")){Array{getfield(Main, Symbol("##89#90")){getfield(Main, Symbol("##67#69")){Array{Array{Float64,1},1}},getfield(Main, Symbol("##76#78")){typeof(sin1),getfield(Main, Symbol("##75#77")){getfield(Main, Symbol("##67#69")){Array{Array{Float64,1},1}},Int64}}},1}}

```

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [November 12, 2018, 3:00am UTC](https://discourse.julialang.org/t/function-vs-getfield/17418/2 "2018-11-12T03:00:09Z")

</div>

This is a more specific subtype of Function.

---

<div class="post-metadata">

**Author:** ![unhandyandy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/unhandyandy/32/7634_2.png) [@unhandyandy](https://discourse.julialang.org/u/unhandyandy)\
**Post date:** [November 12, 2018, 3:12am UTC](https://discourse.julialang.org/t/function-vs-getfield/17418/3 "2018-11-12T03:12:36Z")

</div>

Then why do I get this error?

```julia
julia> testpl = play(testint,16.0)
ERROR: MethodError: no method matching play(::getfield(Main, Symbol("##48#57")){Array{getfield(Main, Symbol("##33#34")){getfield(Main, Symbol("##11#13")){Array{Array{Float64,1},1}},getfield(Main, Symbol("##20#22")){typeof(sin1),getfield(Main, Symbol("##19#21")){getfield(Main, Symbol("##11#13")){Array{Array{Float64,1},1}},Int64}}},1}}, ::Float64, ::getfield(Main, Symbol("##15#17")), ::Float64)
Closest candidates are:
  play(::Function, ::Float64, ::Function) at /home/dabrowsa/lang/julia/mine/sines.jl:8
  play(::Function, ::Float64, ::Function, ::Int64) at /home/dabrowsa/lang/julia/mine/sines.jl:8
  play(::Function, ::Float64) at /home/dabrowsa/lang/julia/mine/sines.jl:8
Stacktrace:
 [1] play(::Function, ::Float64) at /home/dabrowsa/lang/julia/mine/sines.jl:8
 [2] top-level scope at util.jl:156

```

Surely it shoufd match `play(::Function, ::Float64)`?

---

<div class="post-metadata">

**Author:** ![Keno](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/keno/32/285_2.png) [@Keno](https://discourse.julialang.org/u/Keno)\
**Post date:** [November 12, 2018, 3:34am UTC](https://discourse.julialang.org/t/function-vs-getfield/17418/4 "2018-11-12T03:34:57Z")

</div>

It did, as shown by the stacktrace. The next call isn’t matching because the last argument is Float64, but your method is restricted to Int64.

---

<div class="post-metadata">

**Author:** ![unhandyandy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/unhandyandy/32/7634_2.png) [@unhandyandy](https://discourse.julialang.org/u/unhandyandy)\
**Post date:** [November 12, 2018, 3:50am UTC](https://discourse.julialang.org/t/function-vs-getfield/17418/5 "2018-11-12T03:50:36Z")

</div>

Oh - my last argument is `44100/4`, that’s not an integer?

Got it, thanks.

---

<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:** [November 12, 2018, 3:53am UTC](https://discourse.julialang.org/t/function-vs-getfield/17418/6 "2018-11-12T03:53:53Z")

</div>

Right, division of `Int`s always produces a `Float64` in Julia (this is like Python3 but unlike Python2).

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [November 12, 2018, 4:28am UTC](https://discourse.julialang.org/t/function-vs-getfield/17418/7 "2018-11-12T04:28:27Z")

</div>

> [@unhandyandy](#):
>
> 44100/4

```julia
julia> 44100/4
11025.0

julia> 44100÷4
11025

÷ == \div <TAB> == div(44100,4) # Integer division

```
