简体   繁体   English

Swift Combine:无法推断复杂的闭包返回类型错误

[英]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.

相关问题 Swift 无法推断复杂的闭包返回类型 - Swift unable to infer complex closure return type 无法推断出复杂的闭包返回类型; 添加显式类型以消除歧义 - Unable to infer complex closure return type; add explicit type to disambiguate SwiftUI 错误:无法推断复杂的闭包返回类型; 添加显式类型以消除歧义 - SwiftUI Error: Unable to infer complex closure return type; add explicit type to disambiguate “无法推断复杂的闭包返回类型;添加显式类型以消除歧义”SwiftUI 中的错误 - "Unable to infer complex closure return type; add explicit type to disambiguate" Error in SwiftUI 我该如何解决这个“无法推断复杂的闭包返回类型; 添加显式类型以消除歧义”错误? - How can I solve this “Unable to infer complex closure return type; add explicit type to disambiguate” error? 无法推断复杂的闭包返回类型 SwiftUI ForEach - Unable to infer complex closure return type SwiftUI ForEach SwiftUI:ForEach 无法推断复杂的闭包返回类型 - SwiftUI: ForEach Unable to infer complex closure return type SwiftUI ForEach 无法推断复杂的闭包返回类型; 添加显式类型以消除歧义 - SwiftUI ForEach Unable to infer complex closure return type; add explicit type to disambiguate 如何在 SwiftUI 列表/ForEach 中动态创建部分并避免“无法推断复杂的闭包返回类型” - How to dynamically create sections in a SwiftUI List/ForEach and avoid “Unable to infer complex closure return type” Swift 3.0:无法推断当前上下文中的闭包类型PromiseKit - Swift 3.0: Unable to infer closure type in the current context ,PromiseKit
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM