Concat operator

Hi all

I have some code like this:

let first = Observable<Int>.create({ observer -> Disposable in
        observer.onNext(1)
        return Disposables.create()
    })
    let second = Observable.of(4, 5, 6)
    let observableConcat = Observable.concat([first, second])
    observableConcat.subscribe({ (event) in
        print(event)
    })

The book describes the concat operator as: “It subscribes to the first sequence of the collection, relays its elements until it completes, then moves to the next one. The process repeats until all the observables in the collection have been used”.
So that I expected the result from the code snippet would be 1, 4, 5, 6 but what I got is 1 only.
Please teach me what I did misunderstand about the concat operator.
Thanks so much.

This topic was automatically closed after 166 days. New replies are no longer allowed.