Confusing wording in Concurrency chapter

In concurrency chapter, the wording in the Tasks and Task Groups after the second example (before the end of the section) states:

Like the previous example, this example creates a child task for each photo to download it. Unlike the previous example, the for-await-in loop waits for the next child task to finish, appends the result of that task to the array of results, and then continues waiting until all child tasks have finished. Finally, the task group returns the array of downloaded photos as its overall result.

The emphasized part suggests that there is a difference in the way the behavior for-await-in loops of in these two examples.

await withTaskGroup(of: Data.self) { group in
    let photoNames = await listPhotos(inGallery: "Summer Vacation")
    for name in photoNames {
        group.addTask {
            return await downloadPhoto(named: name)
        }
    }


    for await photo in group {
        show(photo)
    }
}

and second example

let photos = await withTaskGroup(of: Data.self) { group in
    let photoNames = await listPhotos(inGallery: "Summer Vacation")
    for name in photoNames {
        group.addTask {
            return await downloadPhoto(named: name)
        }
    }


    var results: [Data] = []
    for await photo in group {
        results.append(photo)
    }


    return results
}

From testing it seems there is not - in first example they are printed in the order they are downloaded and in second example they are appended in the order they are downloaded.
Can this paragraph be changed? (I have no suggestion for fix, as I fail to understand what it means). If the emphasized part is correct, and I am wrong, namely there is a difference in the behavior of for-await-in loops in two examples - could more detail be provided how they can differ, why they differ and when these occurs? As it seems they essentially do the same. (just different actions on the same result in the task group in the same order the tasks are finished).

1 Like

I understand that the difference lies in the second example appending the result of the task to an array of results, rather than in the for-await-in loop itself.

The wording is still not clear. What's the substantial difference between the two loops? In the second loop:

the for-await-in loop waits for the next child task to finish, appends the result of that task to the array of results, and then continues waiting until all child tasks have finished.

In the first loop: the for-await-in loop waits for the next child task to finish, shows the result of that task, and then continues waiting until all child tasks have finished.

What does "Unlike" mean here? They both behave the same - they wait for next child task to finish, do something with the result, and then continue waiting until all the child tasks are finished. If "unlike" refers to printing and appending being different actions, it is obvious, why should it be even mentioned, especially when discussing the behavior of async for loop?