Compare two Maps in Scala

前端 未结 4 1747
刺人心
刺人心 2021-02-06 00:49

Is there any pre-defined function that I can use to compare two Maps based on the key and give me the difference? Right now, I iterate Map1 and foreach key, I check if there is

4条回答
  •  攒了一身酷
    2021-02-06 00:54

    I think the -- operator will do what you're looking for: http://www.scala-lang.org/api/current/index.html#scala.collection.Map@--(xs:scala.collection.GenTraversableOnce[A]):Repr

    Although this will probably only work given the assumption that Map2 is always a subset of Map1...

提交回复
热议问题