我对以下现象感到困惑:(在scala版本2.12.4中)
val muListMap = collection.mutable.ListMap.empty[String, Int]
muListMap += "b" -> 1
muListMap += "a" -> 2
muListMap += "c" -> 3
muListMap += "d" -> 4
println(muListMap) //"Map(d -> 4, a -> 2, b -> 1, c -> 3)"
var immuListMap = collection.immutable.ListMap.empty[String, Int]
immuListMap += "b" -> 1
immuListMap += "a" -> 2
immuListMap += "c" -> 3
immuListMap += "d" -> 4
println(immuListMap) //"ListMap(b -> 1, a -> 2, c -> 3, d -> 4)"
muListMap
的顺序错了!为什么呢?