Why still retain Iterator.remove()
Gernot Neppert
mcnepp02 at googlemail.com
Tue Dec 4 01:01:09 PST 2012
I have to admit that until very recently I'd thought that
java.util.streams.Stream extends java.util.Iterable.
While toying with one of the latest JDK8 snapshots, I realized my mistake.
Immediately a question pops up:
Why does java.util.Stream still return a java.util.Iterator with its
"optional" remove() method?
As far as I can see, Iterator.remove() is nowhere implemented in the entire
streams package, thus it always throws UnsupportedOperationException.
If Stream isn't bound by Iterable's contract anymore, why not simply return
a java.util.StreamIterator without remove()?
(Then, of course, java.util.Iterator could be refactored to exend
StreamIterator)
To me, this looks like a good oppurtunity to clean things up and do away
with one of Java's little idiosyncrasies.
More information about the lambda-dev
mailing list