Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is there no function Stream.flatMap()? [closed]

Why is there no function Stream.flatMap() (without any parameters) to flatten a Stream<Stream<T>>?

It would simply be implemented as Stream.flatMap(o -> o).

In my opinion, this is by far the most common use of flatMap(Function mapper).

like image 580
principal-ideal-domain Avatar asked Jun 15 '15 21:06

principal-ideal-domain


1 Answers

I would imagine because it's trivial to use

import static java.util.function.Function.identity;
...  
streamOfStreams.flatMap(identity())
like image 172
Sotirios Delimanolis Avatar answered Oct 05 '22 12:10

Sotirios Delimanolis