title: Scala: how to understand the flatMap method of Try?
body: <p>The flatMap method of the Success is implemented like this:</p>
  
  <pre><code>  def flatMap[U](f: T =&gt; Try[U]): Try[U] =
      try f(value)
      catch {
        case NonFatal(e) =&gt; Failure(e)
      }
  </code></pre>
  
  <p>I kinda understand what this method is doing, it helps us to avoid writing a lot of catching code.</p>
  
  <p>But in what sense is it similar to the regular flatMap? </p>
  
  <p>A regular flatMap takes a sequence of sequences, and put all the elements into one big "flat" sequence.</p>
  
  <p>But the flatMap method of Try is not really flattening anything.</p>
  
  <p>So, how to understand the flatMap method of Try?</p>