Filtering inside for-comprehension with futures
<p>I am doing something like this: </p>

<pre><code> (for { 
   data &lt;- Future(getData)
   updated = makeChanges(data) if updated != data
   _ &lt;- Future(saveUpdates(updated))
   _ &lt;- Future(recordTransaction)
 } yield ()).recover { case e: NoSuchElementException =&gt; () }
</code></pre>

<p>When filter is not satisfied, it skips the remaining two steps (good!) by throwing an exception (not good), that I have to catch and handle at the end. Using exceptions for flow control does not feel too elegant to me though, I am wondering if there is a better way to do this, aside from the obvious - wrapping all remaining lines with an if statement: </p>

<pre><code>   _ &lt;- if(updated != data) Future(saveUpdates(updated)) else Future.successful(())
   _ &lt;- if(updated != data) ...
</code></pre>