title: How to convert this map/flatMap into a for comprehension in Scala?
body: <p>How to convert this map/flatMap into a for comprehension, and please explain how it works, thanks.</p>
  
  <pre><code>    def compute2(maybeFoo: Option[Foo]): Option[Int] =
        maybeFoo.flatMap { foo =&gt;
        foo.bar.flatMap { bar =&gt;
            bar.baz.map { baz =&gt;
            baz.compute
        }
      }
    }  
  </code></pre>