Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

copy contents of immutable map to new mutable map [duplicate]

Tags:

scala

Possible Duplicate:
How can I convert immutable.Map to mutable.Map in Scala?

How do I create a new mutable map with the contents of the immutable map in Scala?

So far I have tried:

val m:scala.collection.mutable.Map[Int, Double] = scala.collection.mutable.Map[Int, Double](imm.map({case(key, value) => (key -> value) }))

to no avail.

like image 276
dave Avatar asked Jan 28 '12 22:01

dave


1 Answers

val im = Map(1->1.0, 2->3.0)
val mm = collection.mutable.Map[Int,Double]() ++= im
like image 149
Rex Kerr Avatar answered Oct 05 '22 20:10

Rex Kerr