How to combine two MultiMaps in Scala with a union over the value sets in a nice way?
I currently do (given mm1 and mm2 are MultiMaps with identical type):
val tempmm = (mm1.keySet union mm2.keySet).
map{k=>(k,(mm1.getOrElse(k,Set()) union mm2.getOrElse(k,Set())))}
tempmm.foreach{case (k,v) => mm1(k)=v}
Now I have the right result in mm1. But I'm sure there must be a nicer way. Probably even a function in MultiMap.