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

# map(_:_:)

Publishes the values of two key paths as a tuple.

```
func map<T0, T1>(_ keyPath0: KeyPath<Self.Output, T0>, _ keyPath1: KeyPath<Self.Output, T1>) -> Publishers.MapKeyPath2<Self, T0, T1>
```

## Parameters

`keyPath0`

The key path of a property on `Output`.

`keyPath1`

The key path of another property on `Output`.

## Return Value

A publisher that publishes the values of two key paths as a tuple.

## Discussion

In the following example, the [`map(_:_:)`](/documentation/Combine/Publisher/map(_:_:)) operator uses the Swift key path syntax to access the `die1` and `die2` members of the `DiceRoll` structure published by the [`Just`](/documentation/Combine/Just) publisher.

The downstream sink subscriber receives only these two values (as an `(Int, Int)` tuple), not the entire `DiceRoll`.

```
struct DiceRoll {
    let die1: Int
    let die2: Int
}

cancellable = Just(DiceRoll(die1:Int.random(in:1...6),
                            die2: Int.random(in:1...6)))
    .map(\.die1, \.die2)
    .sink { values in
        print ("Rolled: \(values.0), \(values.1) (total: \(values.0 + values.1))")
    }
// Prints "Rolled: 6, 4 (total: 10)" (or other random values).
```

---

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)