String.join for Iterable<T>, not just CharSequence

Michael Rasmussen Michael.Rasmussen at
Thu Apr 11 08:25:44 UTC 2019

Hi Stuart

Thanks for the references to the discussion regarding .stream() on Iterable; 
I had been wondering that myself from time to time why they weren't there.
It has always bothered my, that converting an Iterable to a Stream is a bit
cumbersome, having to go through the spliterator and the StreamSupport.

With the IterableOnce suggestion and Stream implementing it, I agree this
would cover some of the scenarios, still the example with Path is cumbersome,
as you also commented on. I don't know if with IterableOnce it would be a 
good time to revisit the .stream on Iterable question, or this is something
that would fit better in/after Valhalla. IterableOnce does seem to answer some
of the questions raised in the discussions you linked. Sure, there is still
the Iterable<Integer> to IntStream question, while it might be desirable, it
will hopefully be moot come Valhalla (and there's always .mapToInt(i->i)).

The reason for the question was basically, because it seemed like it would
fit well with the existing String.join methods, doing the same thing - taking
the entire Iterable/array and joining them, just applying a mapping function
in between. But again, as you said, it might be too narrow, and we don't want
to clutter classes with utility methods everywhere; the existing String.join
methods are themselves simply convenience methods around StringJoiner.


More information about the core-libs-dev mailing list