title: Scala's for comprehension for Futures and Options
body: <p>I have recently read Manuel Bernhardt's new book <a href="https://manning.com/books/reactive-web-applications" rel="noreferrer">Reactive Web Applications</a>. In his book, he states that Scala developers should <strong>never</strong> use <code>.get</code> to retrieve an optional value.</p>
  
  <p>I want to pick up his suggestions but I am struggling to avoid <code>.get</code> when using for comprehensions for Futures.</p>
  
  <p>Let's say I have the following code:</p>
  
  <pre><code>for {
          avatarUrl &lt;- avatarService.retrieve(email)
          user &lt;- accountService.save(Account(profiles = List(profile.copy(avatarUrl = avatarUrl)))
          userId &lt;- user.id
          _ &lt;- accountTokenService.save(AccountToken.create(userId, email))
        } yield {
          Logger.info("Foo bar")
        }
  </code></pre>
  
  <p>Normally, I would have used <code>AccountToken.create(user.id.get, email)</code> instead of <code>AccountToken.create(userId, email)</code>. However, when trying to avoid this bad practice, I get the following exception:</p>
  
  <pre><code>[error]  found   : Option[Nothing]
  [error]  required: scala.concurrent.Future[?]
  [error]         userId &lt;- user.id
  [error]                ^
  </code></pre>
  
  <p>How can I solve this?</p>