loonyuni
loonyuni

Reputation: 1473

How to filterKeys of hashmap Not in given set

Say I have two hashmaps

val currentMap = Map("current"-> 1)
val newMap = Map("current" -> 1, "new"->2)

Is there a way that I can obtain the "relative complement" of B in A i.e., newMap-currentMap?

New to scala - so sorry that these basic set operations are so complicated for me!

Upvotes: 0

Views: 70

Answers (1)

Jean Logeart
Jean Logeart

Reputation: 53829

You can do:

newMap -- currentMap.keys

Upvotes: 5

Related Questions