Skip to content

Instantly share code, notes, and snippets.

@etorreborre
Last active October 15, 2015 09:09
Show Gist options
  • Save etorreborre/ec7923a91338b67dc3f4 to your computer and use it in GitHub Desktop.
Save etorreborre/ec7923a91338b67dc3f4 to your computer and use it in GitHub Desktop.
Nothing Scala gotcha
\/-(1).fold(
sys.exit(0),
t => { System.err.println(t); sys.exit(1) })
// this doesn't do the right thing, why?
// because it should be
\/-(1).fold(
_ => sys.exit(0),
t => { System.err.println(t); sys.exit(1) })
// But the compiler doesn't complain in the first case because `sys.exit(0)` has type `Nothing` and will gladly pass it as `Int => A`.
// add "-Ywarn-dead-code" to avoid this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment