简体   繁体   中英

'Task' cannot be constructed because it has no accessible initializers

I'm trying new Swift 5.5 await async features and I get that compilation error when I try this in a Playground:

let task1 = Task {
    // ...
}

'Task' cannot be constructed because it has no accessible initializers

I got the example from https://www.hackingwithswift.com/articles/233/whats-new-in-swift-5-5

Any idea?

看起来当前的语法是async { ... }而不是Task { ... } ,目的是在将来的某个构建中使用Task语法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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