I have the following function:
func generateIn() -> Future<Int,Never> {
return Future{ promise in
promise(.success(Int.random(in: 1...10)))
}
}
and I'm calling that function from this variable:
let sub2 = generateIn()
.map { value in
print(value)
return Int(value)
}
But I'm getting this error:
Unable to infer complex closure return type; add explicit type to disambiguate
Any of you knows why I'm getting this error or how can fix it?
I'll really appreciate your help
CodePudding user response:
Do what it asks you to do; tell it what type the closure is.
let sub2 = generateIn()
.map { (value:Int) -> Int in
print(value)
return Int(value)
}