Last active
October 15, 2015 09:09
-
-
Save etorreborre/ec7923a91338b67dc3f4 to your computer and use it in GitHub Desktop.
Nothing Scala gotcha
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\/-(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