---
title: next()
framework: swift
role: symbol
role_heading: Instance Method
path: swift/asyncthrowingstream/iterator/next()
---

# next()

The next value from the asynchronous stream.

## Declaration

```swift
mutating func next() async throws -> Element?
```

## Discussion

Discussion When next() returns nil, this signifies the end of the AsyncThrowingStream. It is a programmer error to invoke next() from a concurrent context that contends with another such call, which results in a call to fatalError(). If you cancel the task this iterator is running in while next() is awaiting a value, the AsyncThrowingStream terminates. In this case, next() may return nil immediately, or else return nil on subsequent calls.
