[英]Swift Combine: Unable to infer complex closure return type error
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我会非常感谢你的帮助
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)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.