September 2015
Intermediate to advanced
250 pages
6h 40m
English
Scala supports the Java semantics for exception handling, but the syntax for try-catch is quite different. Also, Scala does not distinguish between checked and unchecked exceptions—it treats all exceptions as if they’re unchecked.
In Scala you throw exceptions just like in Java; for example:
| | throw new IllegalArgumentException |
Remember, you can leave out the empty parentheses after the class name when creating an instance and semicolons are optional.
Also, you can use a try block just like in Java. Scala, however, doesn’t force you to catch exceptions that you don’t care about—not even checked exceptions. This prevents you from adding unnecessary catch blocks—you simply let the exceptions you don’t care to catch propagate ...
Read now
Unlock full access