Closure tuple does not support destructuring in Xcode 9 Swift 4

前端 未结 4 435
情深已故
情深已故 2020-12-17 07:48

After the gloss project for Swift 4 in Xcode 9

I am getting following error which i have no idea

Closure tuple parameter \'(key: _, value: _)

4条回答
  •  抹茶落季
    2020-12-17 08:25

    I'm using Xcode 11.1 and Swift 5, and ran into this error while using enumerated().map(). I think this example simplifies things a little, but in general this is what fixed it for me. The true error was the compiler unable to infer to return value:

    // Correct Syntax
    let resultModels: [ResultModel] = array.enumerated().map { index, model in
      // code
    }
    
    // Results in the error Closure tuple does not support destructuring
    let resultModels = array.enumerated().map { index, model in
      // code
    }
    

提交回复
热议问题