I was wondering about the Java 8 streams (Stream<E>
), they have the following methods:
forEach(Consumer<? super E> action)
forEachOrdered(Consumer<? super E> action)
What were the arguments against not supplying the following signature?
forEachOrdered(BiConsumer<Integer, ? super E> action)
- Which would then return the index of the item in the stream and the item itself.
With this overload it would be possible to actually use the index in case the stream was ordered.
I am really curious to see what the arguments are against it.
Edit, the same actually holds for Iterator<E>
with forEachRemaining
, and possibly more classes.
If none of the classes provide such option, then I suspect it has been considered for Java 8 and denied.