4 ms·
I mostly concur. > consider offering an iterable or streamable view of the elements. This takes different forms in different languages and libraries: Iterator
by Hackbraten 2y ago
I mostly concur.
> consider offering an iterable or streamable view of the elements. This takes different forms in different languages and libraries: Iterator or Stream in Java
Side note: in Java, please do not offer your clients an Iterator. Not only is an Iterator idiomatically awkward to use, it also restricts your clients from even looking at it more than once. What you probably want is use one of the Collections.unmodifiableXxx() methods to wrap your Iterable in a read-only view. This allows your clients to do anything they want with the Iterable: use a for loop, stream it, or save it for later use.