Possible Duplicate:
“return” and “try-catch-finally” block evaluation in scala
There are two Scala functions:
a): def foo(): Int = try { 1 } finally { 2 }
b): def bar(): Int = try { return 1 } finally { return 2}
I cannot figure out why foo returns 1 but bar returns 2.
This behavior is explained in “Programming in Scala” by M.Odersky, L. Spoon and B.Venners. I have the first edition and section 7.5 (pg. 128) says:
Scala standard library has
scala.util.control.ExceptionAPI that provides small functional library for handling exceptions. See the examples in scaladoc