<!--
{
  "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/Publisher/prepend(_:)-v9sb",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Combine"
    ],
    "preciseIdentifier" : "s:7Combine9PublisherPAAE7prependyAA10PublishersO11ConcatenateVy_AF8SequenceVy_qd__7FailureQzGxGqd__STRd__7ElementQyd__6OutputRtzlF"
  },
  "title" : "prepend(_:)"
}
-->

# prepend(_:)

Prefixes a publisher’s output with the specified sequence.

```
func prepend<S>(_ elements: S) -> Publishers.Concatenate<Publishers.Sequence<S, Self.Failure>, Self> where S : Sequence, Self.Output == S.Element
```

## Parameters

`elements`

A sequence of elements to publish before this publisher’s elements.

## Return Value

A publisher that prefixes the sequence of elements prior to this publisher’s elements.

## Discussion

Use [`prepend(_:)`](/documentation/Combine/Publisher/prepend(_:)-v9sb) to publish values from two publishers when you need to prepend one publisher’s elements to another.

In this example the [`prepend(_:)`](/documentation/Combine/Publisher/prepend(_:)-v9sb) operator publishes the provided sequence before republishing all elements from `dataElements`:

```
let prefixValues = [0, 1, 255]
let dataElements = (0...10)
cancellable = dataElements.publisher
    .prepend(prefixValues)
    .sink { print("\($0)", terminator: " ") }

// Prints: "0 1 255 0 1 2 3 4 5 6 7 8 9 10"
```

---

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)