首页 > 解决方案 > 将其嵌套在 Kotlin 中

问题描述

我应该如何管理 Kotlin 中的嵌套迭代器?我使用了一个过渡变量,但我相信应该有一些更漂亮的解决方案。

arr.forEach {
   val forEachIt = it //I need to get rid of this extra value
   val product = productList.firstOrNull { forEachIt.productId == it.productID }
}

标签: kotlin

解决方案


推荐阅读