The Swift Concurrency documentation provides the following example for how to await multiple async functions in parallel.
async let firstPhoto = downloadPhoto(named: photoNames[0])
async let secondPhoto = downloadPhoto(named: photoNames[1])
async let thirdPhoto = downloadPhoto(named: photoNames[2])
let photos = await [firstPhoto, secondPhoto, thirdPhoto]
Is there a way to await an arbitrary number of async functions in parallel? I tried the approach shown in the code below, but could not find a way to make it work.
var photoPromises: [PhotoPromise] = []
for name in photoNames {
photoPromises.append(downloadPhoto(named: name))
}
let photos = await photoPromises