The question is very simple, is there a way in scala to initialize a Mutable map with a inmutable map?
I want something like this:
import scala.collection.mutable.{ Map => MutableMap }
...
val dumbMap = Map("abc" -> 123)
val theMap = new MutableMap(dumbMap)
of course I could iterate or use the map function to initialize my mutable map and add all the elements in dumbMap
, but... it think it would be ridiculous if scala lacks of such a basic method
SOLUTION EDIT: as mentioned in the previous question, it is not exactly a constructor, but a Method in its companion
val theMap = MutableMap[String, Integer](dumbMap.toSeq: _*)
Pay attention to the types of your map