<!--
{
  "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/AsyncThrowingStream/Continuation/yield(with:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:Scs12ContinuationV5yield4withAB11YieldResultOyxs5Error_p__Gs0E0OyxsAG_pG_tsAG_pRs_rlF"
  },
  "title" : "yield(with:)"
}
-->

# yield(with:)

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

```
@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

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

## 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.

---

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)