Created
January 30, 2020 11:19
-
-
Save ramunasjurgilas/d28ef4b4ef884aad37abf73f4ea70fb5 to your computer and use it in GitHub Desktop.
scan() as transforming operator
This file contains hidden or 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
(1...4) | |
.publisher | |
.scan([]) { (values, value) -> [String] in | |
values + [String(value)] | |
} | |
.sink { print($0) } | |
// Output: | |
// ["1"] | |
// ["1", "2"] | |
// ["1", "2", "3"] | |
// ["1", "2", "3", "4"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment