Why use if/else when you can use try/if/catch?

85 points · 8 comments · view on lemmy.world

8 Comments

lowleveldata@programming.dev · 18 pts · 3y (2 replies)

Why use goto when you can throw exceptions to escape nested for loops?

fiah@discuss.tchncs.de · 9 pts · 3y (1 reply)

exceptions are just fancy gotos

wvenable@lemmy.ca · 1 pts · 3y

Exceptions are fancy returns. Everything else is fancy goto, including returns...

speaker_hat@lemmy.one · 3 pts · 3y

Why throwing an exception without a message, when you can use 0/0

HairHeel@programming.dev · 2 pts · 3y (1 reply)

I don’t see a catch in the screenshot. Maybe this block just has a finally that cleans some things up before the exception is thrown?

qaz@lemmy.world · 1 pts · 3y

It doesn't have a catch block, and it isn't supposed to throw any other exceptions inside the try block either.

cupcakezealot@lemmy.blahaj.zone · 2 pts · 3y

Why use try/if/catch when you can use try/if/switch/catch?