map 和 flatMap
时间: 2023-09-05 08:13:13 浏览: 88
map和flatMap是Scala函数机制中常用的两个函数。map函数将一个函数应用于集合中的每个元素,并将处理后的结果返回。而flatMap函数与map函数类似,但传入的函数在处理完后返回的值必须是一个列表。这样可以进行一对多的转换操作。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [java8中 map和flatmap的共同点和区别,以及两者的实例解析](https://blog.csdn.net/zhuwukai/article/details/82888316)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [map和flatMap](https://blog.csdn.net/mingwulipo/article/details/115233352)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文