---
title: "yield(with:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/asyncthrowingstream/continuation/yield(with:)"
---

# yield(with:)

Resume the task awaiting the next iteration point by having it return normally or throw, based on a given result.

## Declaration

```swift
@discardableResult func yield(with result: sending Result<Element, Failure>) -> AsyncThrowingStream<Element, Failure>.Continuation.YieldResult where Failure == any Error
```

## Parameters

- `result`: A result to yield from the continuation. In the .success(_:) case, this returns the associated value from the iterator’s next() method. If the result is the failure(_:) case, this call terminates the stream with the result’s error, by calling finish(throwing:).

## Return Value

Return Value A YieldResult that indicates the success or failure of the yield operation.

## Discussion

Discussion If nothing is awaiting the next value and the result is success, this call attempts to buffer the result’s element. If you call this method repeatedly, each call returns immediately, without blocking for any awaiting consumption from the iteration.

## See Also

### Producing Elements

- [yield(_:)](swift/asyncthrowingstream/continuation/yield(_:).md)
- [yield()](swift/asyncthrowingstream/continuation/yield().md)
- [AsyncThrowingStream.Continuation.YieldResult](swift/asyncthrowingstream/continuation/yieldresult.md)
