async let a: () = someAsyncFuncThatReturnsVoid()
async let b: () = someAsyncFuncThatReturnsVoid()
_ = await (a, b)
doSomething()
When doSomething() is executed, both a and b should be done.
AFAICS the only reason I have to name a and b is because I have to await them, and the explicit type () is the result of applying the suggested fix from a warning I would get otherwise.
That’s not the best way to “shorten” the task group definition — we’re shipping DiscardingTaskGroup | Apple Developer Documentation for those use cases when you don’t use the results. It’s more efficient in quickly discarding the values.
Though tbh the two async lets are probably the shortest way I guess. And slightly more efficient since async let tasks are allocated in the parent tasks allocator which may not necessarily have to hit the heap.
I too run into this conundrum occasionally, and find the async let approach very boilerplaty. I tend to just use task groups, even if they are less efficient in principle, because the resulting code is much cleaner.