Cannot call value of non-function type 'String'

前端 未结 6 1840
情书的邮戳
情书的邮戳 2021-01-17 07:35

I\'m trying to pass the ILTItem variable into my ILTViewController, triggered by AppDelegate.swift when the user launches my app via a deeplink.

The code I have erro

6条回答
  •  不要未来只要你来
    2021-01-17 07:52

    Works:

    let works = ["foo", "bar"].first(where: { ($0 == "foo") } )
    let works = ["foo", "bar"].first(where: { (_ in true) } )
    

    Fails:

    let fails = ["foo", "bar"].first(where: { (true) } )
    
    // Cannot call value of a non-function type 'String?'
    

    You must be sure to use the parameter ($0 or _ in) in the closure expression.

    Use _ in or $0 to discard or reference the parameter. You cannot simple move directly into the closure body and return true or you will receive this (extremely unhelpful) error.

提交回复
热议问题