Here’s the example - Ideally it should print 4,4,6,6 but does not print anything.
example(of: “TakeWhileWithIndex”) {
Observable.of(2, 2, 4, 4, 6, 6)
.takeWhileWithIndex { value,_ in
value > 2
}
.subscribe(onNext: {
print($0)
})
}
Here’s the example - Ideally it should print 4,4,6,6 but does not print anything.
example(of: “TakeWhileWithIndex”) {
Observable.of(2, 2, 4, 4, 6, 6)
.takeWhileWithIndex { value,_ in
value > 2
}
.subscribe(onNext: {
print($0)
})
}
takeWhileWithIndex returns elements from an observable sequence as long as a specified condition is true. As the first element does not meet the condition, nothing is printed.