iOS Swift - Concurrency
Consider this Swift code snippet using
TaskGroup:
func runTasks() async {
await withTaskGroup(of: Int.self) { group in
group.addTask { 1 }
group.addTask { 2 }
group.addTask { 3 }
var sum = 0
for await value in group {
sum += value
}
print(sum)
}
}
What will be printed when runTasks() is called?