# How to specify parametric type in function argument?

**URL:** <https://discourse.julialang.org/t/how-to-specify-parametric-type-in-function-argument/25641>\
**Category:** New to Julia\
**Created:** [June 25, 2019, 8:17am UTC](https://discourse.julialang.org/t/how-to-specify-parametric-type-in-function-argument/25641 "2019-06-25T08:17:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomtom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomtom/32/5106_2.png) [@tomtom](https://discourse.julialang.org/u/tomtom)\
**Post date:** [June 25, 2019, 8:17am UTC](https://discourse.julialang.org/t/how-to-specify-parametric-type-in-function-argument/25641/1 "2019-06-25T08:17:18Z")

</div>

let’s say I have a parametric type like:

```julia
struct Param{T <: AbstractFloat}
    value::T
end

julia> p1 = Param(3.0)
Param{Float64}(3.0)

julia> p2 = Param(BigFloat(5.0) )
Param{BigFloat}(5.0)

```

how could I “tie” the type of argument `b` in the following function?

```julia
function fun(a::Param{T <: AbstractFloat},
            b::T)
    println(a.value + b)
end

ERROR: UndefVarError: T not defined

```

thanks.

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [June 25, 2019, 8:20am UTC](https://discourse.julialang.org/t/how-to-specify-parametric-type-in-function-argument/25641/2 "2019-06-25T08:20:09Z")

</div>

```julia
function fun(a::Param{T}, b::T) where {T <: AbstractFloat}
    println(a.value + b)
end

```

See for example [here](https://docs.julialang.org/en/latest/manual/methods/#Parametric-Methods-1).

---

<div class="post-metadata">

**Author:** ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)\
**Post date:** [June 25, 2019, 8:20am UTC](https://discourse.julialang.org/t/how-to-specify-parametric-type-in-function-argument/25641/3 "2019-06-25T08:20:10Z")

</div>

```julia
function fun(a::Param{T},
            b::T) where {T<:AbstractFloat}
    println(a.value + b)
end

```
