Многопоточные операции

var nums = [123]

//a value crossing the task boundary
//must be Sendable; an array is a value
//type, so the task gets its own copy
let task = Task { [nums] in
    print("Child task: \(nums)")
}

nums.append(4)
print("Main task: \(nums)")

await task.value
//the task keeps the copy it captured:
//Main task: [1, 2, 3, 4]
//Child task: [1, 2, 3]