Unlike Java, Scala lets you do a bare "try", without either a catch or finally clause:
scala> try { println("Foo") }
Foo
Does this actually have any meaning beyond,
{ println("Foo") }
?
Unlike Java, Scala lets you do a bare "try", without either a catch or finally clause:
scala> try { println("Foo") }
Foo
Does this actually have any meaning beyond,
{ println("Foo") }
?
I don't think so. I think Scala permits a try without a catch or finally because there's no reason to forbid it.
Scala's exception handling works by passing any exceptions to an anonymous catch function. The catch function works by pattern matching the caught exception and, if it doesn't match it will pass the exception up.
The catch function is optional, if it's omitted then the exception is passed straight up. So essentially
try { exceptionThrowingFunction() }
is the same as
exceptionThrowingFunction()
See chapter 6.22 of the language spec pdf for more information.