Created
April 18, 2014 23:41
-
-
Save rcoh/11068694 to your computer and use it in GitHub Desktop.
Why you should never catch throwable.
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
def inlineme(f: => Int): Int = { | |
try { | |
f | |
inlineme { | |
return 0 | |
} | |
} catch { | |
case ex: Throwable => println(ex); return 1 | |
} | |
} | |
def doStuff { | |
val res = inlineme { | |
10 | |
} | |
println("we got: " + res) | |
} | |
doStuff | |
// Prints: | |
// scala.runtime.NonLocalReturnControl | |
// we got: 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment