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

# next(isolation:)

Produces the next element in the compact map sequence.

## Declaration

```swift
mutating func next(isolation actor: isolated (any Actor)?) async throws(AsyncCompactMapSequence<Base, ElementOfResult>.Failure) -> ElementOfResult?
```

## Discussion

Discussion This iterator calls next() on its base iterator; if this call returns nil, next() returns nil. Otherwise, next() calls the transforming closure on the received element, returning it if the transform returns a non-nil value. If the transform returns nil, this method continues to wait for further elements until it gets one that transforms to a non-nil value.
