标签: list scala map scala-collections mutable
如何将地图转换为列表,而scala中的列表中没有地图键?
val mp = collection.mutable.Map[Long, String]() mp(0) = "val0" mp(1) = "val1" mp(2) = "val2" mp.toList //I want: List("val0", "val1", "val2")
答案 0 :(得分:5)
您可能正在寻找
mp.values.toList