title: Difference between flatMap and compactMap in Swift
body: <p>It seems like in <strong>Swift 4.1</strong> <code>flatMap</code> is deprecated. However there is a new method in <strong>Swift 4.1</strong> <code>compactMap</code> which is doing the same thing? 
  With <code>flatMap</code> you can transform each object in a collection, then remove any items that were nil. 
  <br>
  <strong>Like flatMap</strong></p>
  
  <pre><code>let array = ["1", "2", nil] 
  array.flatMap { $0 } // will return "1", "2"
  </code></pre>
  
  <p><strong>Like compactMap</strong>
  <br></p>
  
  <pre><code>let array = ["1", "2", nil] 
  array.compactMap { $0 } // will return "1", "2"
  </code></pre>
  
  <p><code>compactMap</code> is doing the same thing.</p>
  
  <p>What are the differences between these 2 methods? Why did Apple decide to rename the method?</p>