<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/TaskGroup/Iterator/next()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:ScG8IteratorV4nextxSgyYaF"
  },
  "title" : "next()"
}
-->

# next()

Advances to and returns the result of the next child task.

```
mutating func next() async -> TaskGroup<ChildTaskResult>.Iterator.Element?
```

## Return Value

The value returned by the next child task that completes,
or `nil` if there are no remaining child tasks,

## Discussion

The elements returned from this method
appear in the order that the tasks *completed*,
not in the order that those tasks were added to the task group.
After this method returns `nil`,
this iterator is guaranteed to never produce more values.

For more information about the iteration order and semantics,
see `TaskGroup.next()`.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)