#18: Transforming Publishers
Question
// Swift Quiz
— objc.io (@objcio) June 19, 2019
import Combine
let p = Publishers.Sequence<[Int], Error>(sequence: [1, 4, 8])
p .append([3, 8, 10])
.filter { $0 >= 3 }
.count()
let allEven = p.tryAllSatisfy { $0 % 2 == 0 }
allEven.result
// What’s the value of allEven.result?
Solution
Solution: success(false)
— objc.io (@objcio) June 20, 2019
When we modify p by calling append, filter, and count, we don’t change p itself — the result is a new publisher.
Therefore, p still only contains 1,4, and 8 when we call tryAllSatisfy.
https://t.co/s7500CWmAg