Skip to content

Instantly share code, notes, and snippets.

@ramunasjurgilas
Last active February 27, 2020 12:07
Show Gist options
  • Save ramunasjurgilas/a35a8852849d9b24c80926c58382f238 to your computer and use it in GitHub Desktop.
Save ramunasjurgilas/a35a8852849d9b24c80926c58382f238 to your computer and use it in GitHub Desktop.
Combining operator: prepend(_:)
let integers = (10...12).publisher // F
let moreIntegers = (20...22).publisher // A
integers
.prepend(1, 2) // B
.prepend(99...101) // C
.prepend([-100, -200]) // D
.prepend(moreIntegers) // E
.sink { print($0) }
// Output:
// 20 // From A
// 21 // From A
// 22 // From A
// -100 // From D
// -200 // From D
// 99 // From C
// 100 // From C
// 101 // From C
// 1 // From B
// 2 // From B
// 10 // From F
// 11 // From F
// 12 // From F
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment