title: What is the difference between onComplete and foreach for a future in Scala?
body: <p>I wonder the difference between onComplete and foreach when we use a Future in Scala.</p>
  <p><code>f onComplete (_ =&gt; doSomething(_))</code></p>
  <p>and</p>
  <p><code>f foreach (_ =&gt; doSomething(_))</code></p>
  <ol>
  <li><p>Do the above lines of code lead to the same result?</p>
  </li>
  <li><p>If I want to doSomething with Future f only after it's completed. What should I do? Should I use isCompleted like this:</p>
  <p><code>if(f.isCompleted) f onComplete (_ =&gt; doSomething(_))</code></p>
  </li>
  </ol>
  <p>Thank you guys a lot</p>