title: Map with Optional Unwrapping in Swift
body: <p>Say I had the below api : </p>
  
  <pre><code>func paths() -&gt; [String?] {
      return ["test", nil, "Two"]
  }
  </code></pre>
  
  <p>And I was using this in a method where I needed <code>[String]</code>, hence I had to unwrap it using the simple <code>map</code> function. I'm currently doing : </p>
  
  <pre><code>func cleanPaths() -&gt; [String] {
      return paths.map({$0 as! String})
  }
  </code></pre>
  
  <p>Here, the force-cast will cause an error. So technically I need to unwrap the Strings in the <code>paths</code> array. I'm having some trouble doing this and seem to be getting silly errors. Can someone help me out here?</p>