3 ms·
That's a great example of knowing exactly what ??? means: the program is misbehaving and should terminate. It's dead in the current call stack, but over time p
by codebje 4y ago
That's a great example of knowing exactly what ??? means: the program is misbehaving and should terminate.
It's dead in the current call stack, but over time programs change and that is how errors creep in. If it's a precondition that _baz_ is in a particular range for the function to behave, why not check that in an assert and save yourself or a future programmer a ton of stress trying to work out why some unrelated part of the code blew up when they made what seemed like a simple change nine layers up the call stack?
There's no runtime cost to an assert in production code, but it makes your intent clear to both the compiler and other humans.