title: How can I convert this foldLeft : Double expression to use Option[Double] instead?
body: <p>Can anyone help this Scala newbie? Previously, we summed a number of quantities in a list of entities with those quantities with:</p>
  
  <pre><code>sum = entities.foldLeft(0.0)(_ + _.quantity)
  </code></pre>
  
  <p>Now the quantity is an <code>Option[Double]</code>, and so is the sum. How can I convert this using idiomatic Scala?</p>
  
  <p>If any entity's quantity is <code>None</code> then the sum should also be <code>None</code>.
  Otherwise the sum should be <code>Some(total)</code>.</p>
  
  <p>Edit: Putting this thing into a unit test so that I can try all your answers out. Please note that I do need the result to be None if <strong>any</strong> quantity is None, because missing quantities mean we haven't finished yet, so the total should reflect this. Even if you don't get the right answer, if you help lead me or others to it, or help me learn something new, I'll upvote.</p>
  
  <p>Edit: @sepp2k wins for a working solution plus explanation. Thanks to all for the learning!</p>