Skip to content

Instantly share code, notes, and snippets.

@ramunasjurgilas
Created January 30, 2020 10:36
Show Gist options
  • Save ramunasjurgilas/72706178ab618dd60ed3898d3073f6fc to your computer and use it in GitHub Desktop.
Save ramunasjurgilas/72706178ab618dd60ed3898d3073f6fc to your computer and use it in GitHub Desktop.
replaceNil as transforming operator
[1, nil, 3]
.publisher
.replaceNil(with: -1)
.sink { print($0) }
// Output:
// Optional(1)
// Optional(-1)
// Optional(3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment