title: Scala - reduce/foldLeft
body: <p>I have a nested map <code>m</code> which is like:</p>
  
  <p><code>m = Map("email" -&gt; "a@b.com", "background" -&gt; Map("language" -&gt; "english"))</code></p>
  
  <p>I have an array <code>arr = Array("background","language")</code></p>
  
  <p>How do I foldLeft/reduce the array and find the string "english" from the map. I tried this:</p>
  
  <p><code>arr.foldLeft(m) { (acc,x) =&gt; acc.get(x) }</code></p>
  
  <p>But I get this error:</p>
  
  <pre><code>&lt;console&gt;:10: error: type mismatch;
   found   : Option[java.lang.Object]
   required: scala.collection.immutable.Map[java.lang.String,java.lang.Object]
         arr.foldLeft(m) { (acc,x) =&gt; acc.get(x) }
  </code></pre>