kotlin - 将其嵌套在 Kotlin 中
问题描述
我应该如何管理 Kotlin 中的嵌套迭代器?我使用了一个过渡变量,但我相信应该有一些更漂亮的解决方案。
arr.forEach {
val forEachIt = it //I need to get rid of this extra value
val product = productList.firstOrNull { forEachIt.productId == it.productID }
}
解决方案
推荐阅读
- azure - 如何获取 Azure AD 计算机对象的所有详细信息?
- python - 用于 bitstamp API 的 Lua 与 Python。Python 代码有效,但 Lua 无效。为什么?
- angular - 为什么我的角度序列方法不起作用?
- java - 需要一些关于如何解码从 HERE-OLP 以二进制格式下载的 protobuf 文件的建议
- kotlin - kotlin,如何按位置获取子列表
- git - 如何让 VSCode Gutters 显示来自上游的差异
- mysql - 避免在 Jooq 子查询中获取
- javascript - 重构数组中每个对象的异步函数调用的问题
- c# - 导航视图不会自动关闭
- python - 我是否错误地安装了pynco?如何在 python 中使用 NCO 进行故障排除