julia

What does "where T" in julia do without any specification after T?


I'm new to julia and I have not been able to find an explanation of where that fully makes sense to me. So I understand that for example function f(x::T, y::T) where {T<:Number} = true is requiring that both the x and y parameters be numeric types of some sort.

But then there are other functions that will look like function f(X::AbstractMatrix{T}) where T without any specification of what T is supposed to be. Can someone explain what that is doing and when I would want to use this syntax?


Solution

  • where T without anything else is just where {T<:Any} in other words, it's true for all T, but Julia needs you to write something so that `T is defined.