# Elaboration on Parametric Methods

**URL:** <https://discourse.julialang.org/t/elaboration-on-parametric-methods/61531>\
**Category:** General Usage\
**Created:** [May 20, 2021, 6:04pm UTC](https://discourse.julialang.org/t/elaboration-on-parametric-methods/61531 "2021-05-20T18:04:24Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [May 20, 2021, 6:13pm UTC](https://discourse.julialang.org/t/elaboration-on-parametric-methods/61531/3 "2021-05-20T18:13:25Z")

</div>

Edit: @lmiq beat me to it by one minute 😉

The distinction is that the first method requires that the two characters have the _same_ type (and that that must be some subtype of `Character`. Here’s a simpler example:

```julia
julia> function f(x::T, y::T) where {T <: Integer}
         x + y
       end
f (generic function with 1 method)

julia> f(Int32(1), Int64(1))
ERROR: MethodError: no method matching f(::Int32, ::Int64)
Closest candidates are:
  f(::T, ::T) where T<:Integer at REPL[6]:1
Stacktrace:
 [1] top-level scope
   @ REPL[8]:1

julia> function g(x::Integer, y::Integer)
         x + y
       end
g (generic function with 1 method)

julia> g(Int32(1), Int64(1))
2

```

A further difference is that having an explicit type parameter lets you express more complicated relationships, such as:

```julia
julia> function h(x::T, y::Matrix{T}) where {T}
         x * y
       end
h (generic function with 1 method)

julia> h(2.0, ones(Float64, 2, 2))
2×2 Matrix{Float64}:
 2.0 2.0
 2.0 2.0

```

here `h` is a function that will take any `x` and a `y` whose scalar type is the same as the type of `x`, whatever that type may be. That’s not a relationship you can express via dispatch without type variables.

---

_[View the full topic](https://discourse.julialang.org/t/elaboration-on-parametric-methods/61531)._
