Skip to content

Commit

Permalink
[#54] Cosmetic changes in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amaembo committed Jan 14, 2016
1 parent 8ded57a commit ddd8db9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/test/java/one/util/streamex/StreamExTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1669,10 +1669,11 @@ private static <T> StreamEx<T> skip(StreamEx<T> input, int n) {
}

// reimplemented filter operation (TCO)
@SuppressWarnings("unchecked")
private static <T> StreamEx<T> filter(StreamEx<T> input, Predicate<T> predicate) {
return input.<T>headTail((head, tail) -> filter(tail, predicate).prepend(
(T[]) (predicate.test(head) ? new Object[] { head } : new Object[0])));
return input.<T>headTail((head, tail) -> {
StreamEx<T> filtered = filter(tail, predicate);
return predicate.test(head) ? filtered.prepend(head) : filtered;
});
}

@Test
Expand Down

0 comments on commit ddd8db9

Please sign in to comment.