---
title: "map(_:)"
framework: combine
role: symbol
role_heading: Instance Method
path: "combine/publisher/map(_:)-6sm0a"
---

# map(_:)

Publishes the value of a key path.

## Declaration

```swift
func map<T>(_ keyPath: KeyPath<Self.Output, T>) -> Publishers.MapKeyPath<Self, T>
```

## Parameters

- `keyPath`: The key path of a property on Output.

## Return Value

Return Value A publisher that publishes the value of the key path.

## Discussion

Discussion In the following example, the map(_:) operator uses the Swift key path syntax to access the die member of the DiceRoll structure published by the Just publisher. The downstream sink subscriber receives only the value of this Int, not the entire DiceRoll. struct DiceRoll {     let die: Int }

cancellable = Just(DiceRoll(die:Int.random(in:1...6)))     .map(\.die)     .sink {         print ("Rolled: \($0)")     } // Prints "Rolled: 3" (or some other random value).

## See Also

### Identifying properties with key paths

- [map(_:_:)](combine/publisher/map(_:_:).md)
- [map(_:_:_:)](combine/publisher/map(_:_:_:).md)
