为什么没有函数Stream.flatMap()? [英] Why is there no function Stream.flatMap()?

查看:237
本文介绍了为什么没有函数Stream.flatMap()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么没有函数 Stream.flatMap()(没有任何参数)来展平 Stream< Stream< T>>

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

它只是实现为 Stream.flatMap(o - > o)

在我看来,这是迄今为止最常用的 flatMap(函数映射器)

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

推荐答案

我想是因为使用

import static java.util.function.Function.identity;
...  
streamOfStreams.flatMap(identity())

这篇关于为什么没有函数Stream.flatMap()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆