Answer by spacewizard for What is the point of finally in a try catch/except...
If we make a general definition: In fact, if all codes are defined consistently, there is no need for the finally block. However, such a thing was done because it had to be done.For example, it may be...
View ArticleAnswer by Gökhan Mete ERTÜRK for What is the point of finally in a try...
To make it even easier to understand:try{//a}catch{//b}//cIn above code, //c won't execute:if you use "return" inside the try block. **if you use "return" inside the catch block. **if you raise any...
View ArticleAnswer by Yoz for What is the point of finally in a try catch/except finally...
Learn by examplelet v = 0;function f() { try { v = 1; return 2; } finally { v = 3; return 4; } v = 5; return 6;}const r = f();console.log(r, v);following prints "3, 4"
View ArticleAnswer by Jan Turoň for What is the point of finally in a try catch/except...
finally is a syntactic sugar to allow DRY principle in try-catch pattern. Exception is usually thrown if the library code has not enough information to handle some state and wants the client code to...
View ArticleAnswer by supercat for What is the point of finally in a try catch/except...
The purpose of a finally block is to ensure that code gets run in three circumstances which would not very cleanly be handled using "catch" blocks alone:If code within the try block exits via...
View ArticleAnswer by ahmet for What is the point of finally in a try catch/except...
Finally block is executed even if an exception thrown in the try block. Therefore, for instance if you opened a stream before, you may want to close that stream either an exception is thrown or not....
View ArticleAnswer by Massimiliano Peluso for What is the point of finally in a try...
Finally make sure your code is executed even if you get an exception.The finally block is useful for cleaning up any resources allocated in the try block as well as running any code that must execute...
View ArticleWhat is the point of finally in a try catch/except finally statement
I have used try-catch/except-finally variants in many languages for years, today someone asked me what is the point of finally and I couldn't answer. Basically why would you put a statement in finally...
View Article
More Pages to Explore .....