Observable.
all
(predicate)
Determines whether all elements of an observable sequence satisfy a condition.
Example:
res = source.all(lambda value: value.length > 3)
Keyword Arguments: | |
---|---|
predicate (bool) – A function to test each element for a condition. | |
Returns: | An observable sequence containing a single element determining whether all elements in the source sequence pass the test in the specified predicate. |
Return type: | Observable |
Ex-1
------------------------------------------------------------------
Observable.just(1,2,3,4,15).all(x -> x<10).subscribe(System.out::println);
----------------------------------------------------------------------
Ex-2
----------------------------------------------------------------------
List<Integer> list2 = new ArrayList<>();
list2.add(1);
list2.add(2);
list2.add(7);
list2.add(8);
list2.add(8);
list2.add(9);
list2.add(10);
list2.add(3);
list2.add(11);
list2.add(4);
list2.add(5);
list2.add(5);
list2.add(6);
list2.add(11);
list2.add(12);
Observable.fromIterable(list2).all(x -> x<50).subscribe(System.out::println);
-----------------------------------------------------------------------------
22
No comments:
Post a Comment