How to check whether key or value exist in Map?
There are several different options, depending on what you mean. If you mean by “value” key-value pair, then you can use something like myMap.exists(_ == (“fish”,3)) myMap.exists(_ == “fish” -> 3) If you mean value of the key-value pair, then you can myMap.values.exists(_ == 3) myMap.exists(_._2 == 3) If you wanted to just test the … Read more