3 ms·
>You do arithmetic on them, get a value outside of the range, and then it throws an exception. And an unhandled exception crashes the program, which is often wo
by pydry 6y ago
>You do arithmetic on them, get a value outside of the range, and then it throws an exception. And an unhandled exception crashes the program, which is often worse than an invalid value.
IMO an exception (failing fast) is always better than an invalid value.
Exceptions like these also excel at finding dangerous edge cases when paired with a decent test suite.