0

Finally

When we use finally in exceptions?

27th Apr 2018, 10:32 AM
Aleksandr Efremov
Aleksandr Efremov - avatar
4 ответов
+ 3
Finally will run after the try and catch statements. it will execute regardless of whether there was an error or not. Use finally if you are, for instance, working with files and need to close the file stream. You could do this in finally because you want it to always be called, even if there is an error
27th Apr 2018, 10:51 AM
Ariela
Ariela - avatar
0
Thank you! Do you know other examples when we use finally?
27th Apr 2018, 10:53 AM
Aleksandr Efremov
Aleksandr Efremov - avatar
0
Basically anytime you need to clean something up.
27th Apr 2018, 10:56 AM
Ariela
Ariela - avatar
0
Awesome, thanks!
27th Apr 2018, 10:56 AM
Aleksandr Efremov
Aleksandr Efremov - avatar