Is there a way to type constrain a parameter to more than one constraint? Specifically, the object could be of the protocol Decodable or an Array with generic Decodable.
So like this:
func myFunc(obj:Decodable, Array<Decodable>)
I've tried approaching it like this, using a generic with multiple constraints, but it requires both to be protocals, which Array is not. Also, this is likely an AND constraint, not an OR as pointing out by MartinR:
func myFunc<T where T:Decodable, T:Array<Decodable>>(obj:T)
That fails because array is not a protocol. Is there a way to constrain a parameter to be one of two types, where one is not a protocol?
I'm trying to avoid a check that throws an error at runtime, which I could do, but seems like bad practice to me.