title: Scala Option[Future[T]] to Future[Option[T]]
body: <p>How can I convert <code>Option[Future[T]]</code> to <code>Future[Option[T]]</code> in scala?</p>
  
  <p>I want to use it in:</p>
  
  <pre><code>val customerAddresses = for {
    a &lt;- addressDAO.insert(ca.address) // Future[Address]
    ia &lt;- ca.invoiceAddress.map(addressDAO.insert) // Option[Future[Address]]
  } yield (a, ia) // Invalid value have to be two futures
  </code></pre>
  
  <p>Here signature insert method</p>
  
  <pre><code>def insert(address: Address): Future[Address]
  </code></pre>
  
  <p><code>ca</code> is a CustomerData</p>
  
  <pre><code>case class CustomerData(address: Address, invoiceAddress: Option[Address])
  </code></pre>