Let\'s assume an array of Result. We want the array to be reduced to a Result of an array. For example:
let z: [Result
You can move constraints to the function to make it generic:
extension Array {
func reduced() -> Result<[T], Error> where Element == Result {
return self.reduce(.success([T]())) { accumulator, result in
...
}
}
}
Note: A variable of type Int will not match Any as it's a different type. Variables of type Any need to be casted down to Int.