Kotlin错误:未解决的引用:合并(对于list.merge()) [英] Kotlin Error: Unresolved reference: merge (for list.merge())

查看:136
本文介绍了Kotlin错误:未解决的引用:合并(对于list.merge())的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据来自此处:

val list = listOf(1,2,3,4,5,6)
val listRepeated = listOf(2,2,3,4,5,5,6)
println(list.merge(listRepeated) { it1, it2  -> it1 + it2 })

我收到以下错误消息:

Error:(33, 18) Kotlin: Unresolved reference: merge
Error:(33, 40) Kotlin: Cannot infer a type for this parameter. Please specify it explicitly.
Error:(33, 45) Kotlin: Cannot infer a type for this parameter. Please specify it explicitly.

如何获取此代码以进行正确编译?

How can I get this code to properly compile?

推荐答案

merge已在Kotlin 1.0 Beta 2中删除,如

merge has been dropped in Kotlin 1.0 Beta 2 as described here.

正如@tim_yates所说,此代码示例将为您提供与文章中相同的输出:

As @tim_yates said, this code sample will give you the same output as in the article:

val list = listOf(1,2,3,4,5,6)
val listRepeated = listOf(2,2,3,4,5,5,6)
println(list.zip(listRepeated) { it1, it2  -> it1 + it2 })

这篇关于Kotlin错误:未解决的引用:合并(对于list.merge())的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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