---
title: "compactMap(_:)"
framework: combine
role: symbol
role_heading: Instance Method
path: "combine/publishers/trycompactmap/compactmap(_:)"
---

# compactMap(_:)

## Declaration

```swift
func compactMap<T>(_ transform: @escaping (Output) throws -> T?) -> Publishers.TryCompactMap<Upstream, T>
```
