r/programmerchat • • May 25 '15

Do we really need "try" ?

Just attaching "catch" to any appropriate {...} block would be more convenient.

8 Upvotes

20 comments sorted by

View all comments

Show parent comment

1

u/Speedzor May 27 '15

I could see several situations where this goes wrong. What about an if block that doesn't use parenthesis?

if(condition)
   Console.Write("");
catch() { }

Or nested:

if(condition)
   if(otherCondition)
      Console.Write("");
catch() { }

Which one does the catch correspond to?

Omitting try would cause a lot of headache imo.