I have a problem with type mismatch in Scala. Compiler returns an error:
error: type mismatch; found : Int required: String val v3:Int = (v1+v2)
This is code of my function:
def sumMaps[T, Int](m1: Map[T, Int], m2: Map[T, Int]): Map[T, Int] = {
val sameKeys = m1.keySet.intersect(m2.keySet)
var m3: Map[T, Int] = m1 ++ m2
for (key <- sameKeys) {
val v1:Int = m1(key)
val v2:Int = m2(key)
val v3:Int = (v1+v2)
//val v:Int = (m1(key) + m2(key))
m3 = m3 updated (key, v3)
}
m3
}
Why? Any idea what could be the problem?