我是Kotlin的新手,因为下面的代码:
fun a(stcd: String) {
val res = mutableSetOf<String>()
val aaa = mutableListOf<Map<String, Set<String>>>()
aaa.stream().filter { x: Map<String, Set<String>> -> x.isNotEmpty() }
.filter { x: Map<String, Set<String>> ->
x.values.contains(stcd) // throws error
}.forEach { x: Map<String, Set<String>> ->
x.forEach { (k: String, v: Set<String>?) ->
res.add(k)
}
}
}
有人能指出原因吗
contains
抛出错误:
Type inference failed. The value of the type parameter T should be mentioned in input types (argument types, receiver type or expected type). Try to specify it explicitly.
?