Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'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?

like image 335
Sergio Avatar asked Jul 22 '26 01:07

Sergio


1 Answers

It seems to me that you are referencing another Foundation named Task.

_Concurrency.Task {
     //brabra
}

Did you use it like this

typealias Task = _Concurrency.Task

Specify it like this and use it

like image 153
Donghyuk Lee Avatar answered Jul 24 '26 15:07

Donghyuk Lee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!