현재 우리는 자바 8 Stream.concat
을 다음 있습니다 :Java 8에는 스트림의 varags에서 작동하는 Stream.concat이 부족합니까?
public static <T> Stream<T> concat(Stream<? extends T> a, Stream<? extends T> b);
내가 Stream<? extends T>
의 가변 인자를 가지고 어떤 버전이없는 이유에 놀란다? 이 서명의 가변 인자를 사용할 수 있다면
Stream<Integer> resultStream = Stream.concat(stream1, Stream.concat(stream2, Stream.of(element)))
.filter(x -> x != 0)
.filter(x -> x != 1)
.filter(x -> x != 2);
:
은 현재 내가 코드처럼 작성했습니다
Stream<Integer> resultStream = Stream.concat(
stream1,
stream2,
Stream.of(element)
)
.filter(x -> x != 0)
.filter(x -> x != 1)
.filter(x -> x != 2);
:
public static <T> Stream<T> concat(Stream<? extends T>... streams);
가 그럼 난으로 훨씬 더 명확하게 쓸 수
모든 종류의 중첩 된 Stream.concat
호출없이.
또는 제공되지 않는 다른 이유가 있습니까?
나는 그런 이유로 생각할 수 없다. 어쨌든 지금은 varargs 호출 작업을 끝내기 때문이다.
당신이 스레드를 통과 할 수 있습니다 -> http://mail.openjdk.java.net/pipermail/lambda-dev/2013-July/010647.html –