eli5: In programming, how does using “try and except/catch” blocks stop the program from crashing?

611 views

eli5: In programming, how does using “try and except/catch” blocks stop the program from crashing?

In: 10

20 Answers

Anonymous 0 Comments

In many programming languages, if you try to perform an “illegal action” the program will crash because you’ve attempted the impossible (like dividing by zero) or the disallowed (like accessing memory you’re not supposed to).

The **try** block basically says “check this code for illegal actions, and if there are any, go to the **catch** block. If there aren’t any, do the code.”

You are viewing 1 out of 20 answers, click here to view all answers.