title: Using find function for maps in scala
body: <p>I am trying to find a key in a Map, given a value. I am using the 'find' function by not able to figure out the right predicate for it:</p>
  
  <pre><code>val colors = Map(1 -&gt; "red", 2 -&gt; "blue")
  def keyForValue(map: Map[Int, String], value: String) = {
      val bool = map.find{map.foreach{map.values(i) == value}}
          bool.key
    }
  </code></pre>
  
  <p>How do I iterate over the map and find the key when I know the value?</p>