简体   繁体   English

函数声明中的预期标识符

[英]expected identifier in function declaration swift

When i upgrade swift 1.2 to swift 2.0 following error occurs 当我将Swift 1.2升级到Swift 2.0时,发生以下错误

expected identifier in function declaration swift 函数声明中的预期标识符

here is code 这是代码

internal func try(block: () -> Int32) {
    perform { if block() != SQLITE_OK { assertionFailure("\(self.lastError!)") } }
}

can you help how to solve this 你能帮忙解决这个问题吗

try is a keyword in Swift 2.0 for the do ... try ... catch ... statement, so you should change the name of your function, for instance: try是Swift 2.0中do ... try ... catch ...语句的关键字,因此您应该更改函数名称,例如:

internal func myTry(block: () -> Int32) {
    perform { if block() != SQLITE_OK { assertionFailure("\(self.lastError!)") } }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM