---
title: "init(upstream:initialResult:nextPartialResult:)"
framework: combine
role: symbol
role_heading: Initializer
path: "combine/publishers/scan/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 closure along with the last value returned by the closure.

## Declaration

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

## Parameters

- `upstream`: The publisher that this publisher receives elements from.
- `initialResult`: The previous result returned by the nextPartialResult closure.
- `nextPartialResult`: A closure that takes as its arguments the previous value returned by the closure and the next element emitted from the upstream publisher.
