in java, if there is a exception in code and you are untreated or not throwing out, compiling will be failed. But in scala, it will be compiling successfully.
So how to know whether there is a exception that untreated in scala code?
in java, if there is a exception in code and you are untreated or not throwing out, compiling will be failed. But in scala, it will be compiling successfully.
So how to know whether there is a exception that untreated in scala code?
The situation is the same as for unchecked exceptions (RuntimeExceptions) in Java: the compiler won't complain about them not being handled.
You have to rely on the source code and documentation to see what exceptions you might get from a piece of code.
In Scala, you should probably avoid exceptions in favour of Try
monads when you expect the caller to deal with them (i.e. when you would use a checked exception in Java).