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