Hi, I’m trying to figure out whether its possible to write a signature for a function f(x, y)
such that y
can be converted to x
via convert
. Actually it is a bit simpler: I want to constraint x
and y
to be both either <:SMatrix{N,N}
with the same N
or both <:Number
.
I could of course write
f(x::Number, y::Number) = ...
f(x::SMatrix{N,N}, y::SMatrix{N,N}) where {N} = ...
but then I would need to write the same code twice (both methods are identical). In order to follow DRY I would like to write a single signature that picks both cases. Is it possible? (Note that making both x
and y
::Union{Number, SMatrix{N,N}}
doesn’t work, as it doesn’t exclude the case of having one Number
and one SMatrix
).