Exceptions are an alternative to function return values. The big differences are:
Exceptions cannot be ignored. They must be caught or the app will crash. It is a way of
forcing the caller of a function to deal with an exceptional condition.
It is also an improvement over return values, because you can put all possible values of your
return type to good use, instead of having to dedicate one or more values as the "invalid"
value.
In addition, exceptions allow you to jump out of deeply nested function calls conveniently,
avoiding a lot of return type checking and conditional statements.
Exceptions cannot be ignored. They must be caught or the app will crash. It is a way of
forcing the caller of a function to deal with an exceptional condition.
It is also an improvement over return values, because you can put all possible values of your
return type to good use, instead of having to dedicate one or more values as the "invalid"
value.
In addition, exceptions allow you to jump out of deeply nested function calls conveniently,
avoiding a lot of return type checking and conditional statements.
Comments
Post a Comment
https://gengwg.blogspot.com/