<!--
{
  "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/init(upstream:initialResult:nextPartialResult:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Combine"
    ],
    "preciseIdentifier" : "s:7Combine10PublishersO7TryScanV8upstream13initialResult011nextPartialG0AEy_xq_Gx_q_q_q__6OutputQztKctcfc"
  },
  "title" : "init(upstream:initialResult:nextPartialResult:)"
}
-->

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

```
init(upstream: Upstream, initialResult: Output, nextPartialResult: @escaping (Output, Upstream.Output) throws -> Output)
```

## Parameters

`upstream`

The publisher that this publisher receives elements from.

`initialResult`

The previous result returned by the `nextPartialResult` closure.

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