Skip to content

Instantly share code, notes, and snippets.

@jrudolph
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrudolph/e1f62f5517a839c7bb81 to your computer and use it in GitHub Desktop.
Save jrudolph/e1f62f5517a839c7bb81 to your computer and use it in GitHub Desktop.
for / yield desugaring
> scala -Xprint:parser
scala> trait A { def getB: Int }
scala> def getA(): A = null
scala> def x = for { a <- Option(getA()); b <- Option(a.getB) } yield b
[[syntax trees at end of parser]] // <console>
[... snip ...]
def x = Option(getA()).flatMap(((a) => Option(a.getB).map(((b) => b))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment