Daily iOS
Concurrency

async let vs TaskGroup

A banking app's home screen has to fetch independent account, card, and notification data at the same time. Between async let and TaskGroup, which would you pick, and on what basis?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

If the number and types of requests are fixed in code, like the three for accounts, cards, and notifications, three lines of async let are right; if the count is decided at runtime, like fetching a balance for each of n accounts, use a TaskGroup. The criterion is whether the number of children is known at compile time.

Share a question