The general Map interface does not guarantee such a guarantee. It also cannot be, as this would preclude HashMap as a possible implementation.
I believe that collection.immutable.ListMap maintains the insertion order, you can also use LinkedHashMap through the Map interface, which will then prevent access to any mutator methods. This is simple enough to do by explicitly specifying the type:
val m: scala.collection.Map[Int,Int] = collection.mutable.LinkedHashMap(1->2, 2->3)
or (using type):
val m = collection.mutable.LinkedHashMap(1->2, 2->3) : Map[Int,Int]
source share