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

# Publishers.Scan

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.

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

## Topics

### Creating a scan publisher

[`init(upstream:initialResult:nextPartialResult:)`](/documentation/Combine/Publishers/Scan/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.

### Declaring supporting types

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

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

[`Failure`](/documentation/Combine/Publishers/Scan/Failure)

The kind of errors this publisher might publish.

### Inspecting publisher properties

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

The publisher that this publisher receives elements from.

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

The previous result returned by the `nextPartialResult` closure.

[`nextPartialResult`](/documentation/Combine/Publishers/Scan/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.

## Relationships

### Conforms To

[`Publisher`](/documentation/Combine/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)