---
title: "init(upstream:predicate:)"
framework: combine
role: symbol
role_heading: Initializer
path: "combine/publishers/removeduplicates/init(upstream:predicate:)"
---

# init(upstream:predicate:)

Creates a publisher that publishes only elements that don’t match the previous element, as evaluated by a provided closure.

## Declaration

```swift
init(upstream: Upstream, predicate: @escaping (Publishers.RemoveDuplicates<Upstream>.Output, Publishers.RemoveDuplicates<Upstream>.Output) -> Bool)
```

## Parameters

- `upstream`: The publisher from which this publisher receives elements.
- `predicate`: A closure to evaluate whether two elements are equivalent, for purposes of filtering. Return true from this closure to indicate that the second element is a duplicate of the first.
