Skip to content

Instantly share code, notes, and snippets.

@bartjacobs
Created November 23, 2020 16:07
Show Gist options
  • Save bartjacobs/22ca244a6120d44491ff56f36071909b to your computer and use it in GitHub Desktop.
Save bartjacobs/22ca244a6120d44491ff56f36071909b to your computer and use it in GitHub Desktop.
import Combine
let numbers: [Int?] = [1, 2, nil, 3, 4]
numbers.publisher
.filter { $0 != nil }
.sink { print($0) }
numbers.publisher
.compactMap { $0 }
.sink { print($0) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment