Getting the last two values from an RxSwift Observable

I really can't remember why, but at some point I needed to get a RxSwift Observable's last two values, to compare them and decide what to do next.

Searching around, most answers I found looked a bit too complex to read and too verbose for something that seemed like it should be simple.

Observable Current and Previous Value
I have a Variable which is an array of enum values. These values change over time. enum Option { case One case Two case Three} let options = Variable<[Option]>([ .One, .Two, .T...

It turns out, there is a simple solution. One that only takes one line:

Observable.zip(ourObservable, ourObservable.skip(1))

Here, the left-hand value will be the previous value, and the right-hand value will be the latest value.

Yes, that's it. Thank you, duan!