Description
RxJava 2.2.17
The following method:
public static <T, R> Single<R> zip(final Iterable<? extends SingleSource<? extends T>> sources, Function<? super Object[], ? extends R> zipper)
throws NoSuchElementException if the Iterable sources
is empty. This is very unfortunate, and it goes against functional programming principles.
The zipper
function should be invoked with an empty array - and if zipper
can handle empty Iterable - it will produce a value R
. If zipper
cannot handle an empty array - it's up to zipper
to throw an exception. Basically, RxJava shouldn't put artificial constraints on the Iterable.
In my specific case, the zipper
function is Kotlin's Iterable<T>.all(predicate: (T) -> Boolean)
- which falls back to true
if Iterable is empty - and that's what I want to receive - a Single of true
.
Thanks.