为什么HashMap.merged不能在Map上工作?例如:
val resultMap = collection.immutable.HashMap[String, Int]()
val justMap = collection.immutable.Map[String, Int]()
resultMap.merged(justMap)
答案 0 :(得分:0)
类型不匹配,请检查ScalaDoc。请改用++
运算符:
val firstMap = collection.immutable.HashMap[String, Int]()
val secondMap = collection.immutable.Map[String, Int]()
val resultMap = firstMap ++ secondMap