RFR: 8180352: Add Stream.toList() method
Tagir Valeev
amaembo at gmail.com
Wed Nov 4 09:24:04 UTC 2020
Hello!
On Wed, Nov 4, 2020 at 4:16 PM Justin Dekeyser
<justin.dekeyser at gmail.com> wrote:
> What about trying to make the Stream interface *flexible* to users,
> instead of adding new functionalities that we could regret later?
> Then, as the language usages and the trends evolve, we could really
> see which of the "utils" functions are relevant to add.
>
> For example, we could maybe invent a method of the form (just a
> sketch, not an actual well thought proposal)
> `
> default <S extends Stream<T>> S wrap(Function<Stream<T>, S> wrapper) {
> return wrapper.apply(this);
> }
> `
> on Stream<T> interface, in such a way one could use the "natural flow"
> of writing while binding its own implementation and, therefore, use
> its own shortcuts.
See https://bugs.openjdk.java.net/browse/JDK-8210372
(also, String::transform)
With best regards,
Tagir Valeev
More information about the core-libs-dev
mailing list