4 ms·
Not sure if serious, but assert only makes sense in cases where you want to switch off the tests at some point right?
by DeepDuh 14y ago
Not sure if serious, but assert only makes sense in cases where you want to switch off the tests at some point right?
- huhtenberg 14y agoAsserts are for enforcing invariants in the code. If you replace an assert with a conditional that allows the execution to continue, you are concealing the problem and making it that much harder to track. Practically speaking, your function should not be failing because your other code passed it invalid parameters. That's a bug in the former. That's why parameter validity should be asserted.
- DeepDuh 14y agoI see. I usually never let execution continue and log + exit instead, but you're right, an assert is easier in that situation.