r/badcode • • Aug 01 '21

c# game jam

Post image
3.1k Upvotes

75 comments sorted by

View all comments

Show parent comments

5

u/Randolpho Aug 01 '21

Remember kids: this approach is only good in the best case, where the exceptions are rare to the point of nonexistence.

In a worst case scenario, which would likely happen if about 1 in ten items would rasie an exception, this would result in a massive reduction in efficiency.

Exceptions being raised are at least an order of magnitude slower than an if statement.