-1

I have a method:

def mergeMaps(map1: mutable.Map[K, V], 
              map2: mutable.Map[K, V]): mutable.Map[K, V] = {
       // merge logic here
       m1
}

I tried using Scalaz but for some reason, it says symbol |+| cannot be found. NOTE: I imported scalaz._ and Scalaz._

user10751899
  • 147
  • 1
  • 9

1 Answers1

2

You can concatenate two maps as follows: m1 ++ m2 so, your function should look like this,

def mergeMaps(map1: mutable.Map[K, V], map2: mutable.Map[K, V]): mutable.Map[K, V] = { // merge logic here m1 ++ m2 }

This blog post (http://scala4fun.tumblr.com/post/84792374567/mergemaps) could help. I'm not really sure about the imports but as I currently understand it, this is the conventional way to merge two maps. Also, are you merging these maps by key?, if so, there is a way to do that in Scala. I hope this helps.