本文主要是介绍Kotlin HashMap entries.filter过滤forEach,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Kotlin HashMap entries.filter过滤forEach
fun main(args: Array<String>) {val hashMap = HashMap<String, Int>()hashMap["a"] = 1hashMap["b"] = 2hashMap["c"] = 3println(hashMap)hashMap.entries.filter {println("filter ${it.key}-${it.value}")it.key == "b" //此处为过滤条件,满足过滤条件为真,才会进入forEach}.forEach {println("forEach ${it.key}--${it.value}")}
}
{a=1, b=2, c=3}
filter a-1
filter b-2
filter c-3
forEach b--2
kotlin协程flow filter map flowOn zip combine(1)_zhangphil的博客-CSDN博客一、flow ,emit,onCompletion,collect。四、map,重组改写数据。八、conflate 合并。九、debounce去重。二、函数作为flow。https://blog.csdn.net/zhangphil/article/details/130084723
这篇关于Kotlin HashMap entries.filter过滤forEach的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!