Finding Duplicate (Key, Value) in Map I wrote a function for checking if a Map[(String, String)] contains an element with a matching key and value:

  def findDupes(map: Map[String, String], key: String, value: String): 
                           Option[(String, String)] = {
    val dupes = map.collect { case (x, y) if(x == key &amp;&amp; y == value) =&gt; key }
    dupes match {
      case Nil     =&gt; None
      case x :: _  =&gt; Some(key, value)
    }
  }


Testing

scala&gt; map
res10: scala.collection.immutable.Map[String,String] = Map(1 -&gt; HELLO, 2 -&gt; WORLD)

scala&gt; findDupes(map, "1", "HELLO")
res8: Option[(String, String)] = Some((1,HELLO))

scala&gt; findDupes(map, "1", "FOO")
res9: Option[(String, String)] = None
Use map get key contains value, to test if a given key-value-pair is already part of a Map.

Your solution is extremely inefficient, because you iterate through the entire Map (with collect) just to find one value. get returns an Option which can be checked for the containing value.