<!--
{
  "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" : "Combine",
  "identifier" : "/documentation/Combine/Publishers/TryScan",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Combine"
    ],
    "preciseIdentifier" : "s:7Combine10PublishersO7TryScanV"
  },
  "title" : "Publishers.TryScan"
}
-->

# Publishers.TryScan

A publisher that transforms elements from the upstream publisher by providing the current element to a failable closure along with the last value returned by the closure.

```
struct TryScan<Upstream, Output> where Upstream : Publisher
```

## Topics

### Creating a try-scan publisher

[`init(upstream:initialResult:nextPartialResult:)`](/documentation/Combine/Publishers/TryScan/init(upstream:initialResult:nextPartialResult:))

Creates a publisher that transforms elements from the upstream publisher by providing the current element to a failable closure along with the last value returned by the closure.

### Declaring supporting types

[`Publishers.Output`](/documentation/Combine/Publishers/Output)

A publisher that publishes elements specified by a range in the sequence of published elements.

[`Publishers.TryScan.Failure`](/documentation/Combine/Publishers/TryScan/Failure)

The kind of errors this publisher might publish.

### Inspecting publisher properties

[`upstream`](/documentation/Combine/Publishers/TryScan/upstream)

The publisher that this publisher receives elements from.

[`initialResult`](/documentation/Combine/Publishers/TryScan/initialResult)

The previous result returned by the `nextPartialResult` closure.

[`nextPartialResult`](/documentation/Combine/Publishers/TryScan/nextPartialResult)

An error-throwing closure that takes as its arguments the previous value returned by the closure and the next element emitted from the upstream publisher.



---

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)