没有更多上下文 Swift 的表达式类型不明确 [英] Type of expression is ambiguous without more context Swift

查看:41
本文介绍了没有更多上下文 Swift 的表达式类型不明确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试升级到最新 Swift 版本的项目中的这部分代码出现表达式类型不明确,没有更多上下文".我似乎无法弄清楚.我尝试了不同的方法,但无法正常工作.

I am getting a 'Type of expression is ambiguous without more context ' on this part of code from a project I am trying to upgrade to latest Swift version. I can't seem to figure it out. I tried different things but can't get it to work.

问题出在这一行的语法上

The problem is on the syntax of this line

let imageToDeleteParameters  = imagesToDelete.map { ["id": $0.id, "url": $0.url.absoluteString, "_destroy": true] }

完整代码:

extension TutorialCreationRequest: WebserviceParametrable {
    func toParameters() -> [String: AnyObject] {
        let imageParameters = images.map { ["url": $0] }
        let imageToDeleteParameters  = imagesToDelete.map { ["id": $0.id, "url": $0.url.absoluteString, "_destroy": true] }
        return [
            "title": title,
            "is_draft": isDraft,
            "difficulty": difficulty,
            "duration": duration,
            "cost": cost,
            "user_id": userId,
            "description": description,
            "to_sell": toSell,
            "images": [imageParameters, imageToDeleteParameters].flatMap { $0 }
        ]
    }
}

推荐答案

当函数的参数名称错误时会发生这种情况.

This happens when you have a function with wrong argument names.

示例:

functionWithArguments(argumentNameWrong: , argumentName2: )

并且您将函数声明为:

functionWithArguments(argumentName1: , argumentName2: ){}

这通常发生在您更改变量名称时.确保在执行此操作时进行重构.

This usually happens when you changed the name of a Variable. Make sure you refactor when you do that.

这篇关于没有更多上下文 Swift 的表达式类型不明确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆