Last active
February 27, 2020 12:07
-
-
Save ramunasjurgilas/a35a8852849d9b24c80926c58382f238 to your computer and use it in GitHub Desktop.
Combining operator: prepend(_:)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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