Group Group Group Group Group Group Group Group Group

replaceNil two implementations

I read Chapter 3 and found it strange that after the replaceNil operator I had to do map with force unwrapping.

It turned out that this is because replaceNil has two implementations for Publishers.Sequence.

_ = Just<Int?>(1)
    .replaceNil(with: 2) // Publishers.Map<Just<Int?>, T>
    .sink(receiveValue: { (value: Int) in
        print(value)
    })

_ = [1, nil, 3]
    .publisher
    .replaceNil(with: 2) // Publishers.Sequence<[Publishers.Sequence<Elements, Failure>.Output], Failure>
    .sink(receiveValue: { (value: Int?) in
        print(value)
    })

_ = [1, nil, 3]
    .publisher
    .replaceNil(with: 2) // Publishers.Map<Publishers.Sequence<[Int?], Never>, T>
    .sink(receiveValue: { (value: Int) in
        print(value)
    })

@scotteg Can you please help with this when you get a chance? Thank you - much appreciated! :]

Sorry this is a duplicate of Errata for Combine: Asynchronous Programming with Swift 1st Edition (v1.0.3)