Use Either to allow multiple result types to be combined into one. You can then switch over the specific types to evaluate the result. Either can be used as described below.
let _b = false
func b() -> Either<String, Int> {
if _b {
return *""
} else {
return *1
}
}
func test() {
let c = b()
c.switch(
first: { string in
},
second: { int in
}
)
}