Unitful dispatch

Just don’t specify the units you want, instead specify the dimensions. E.g. in this case, you want any Quantity which has dimensions of 𝐓^-1, so you just do

julia> using Unitful; using Unitful: Hz, s, 𝐓

julia> f(x::Quantity{<:Any, 𝐓^-1}) = 2x
f (generic function with 1 method)

julia> f(2.0Hz)
4.0 Hz

julia> f(1/0.5s)
4.0 s^-1
5 Likes