How to get the base type of a `Complex`

Hi, here is what I have

realtype(::Type{T}) where {T<:Real} = T
realtype(::Type{Complex{T}}) where {T<:Real} = T

I wonder if there is a recommended (Base-y) way to do this? Thanks!

You know that you can just use real for this, right?

julia> real(Float64)
Float64

julia> real(ComplexF64)
Float64
2 Likes