4 ms·
precondition is something which must be true before some code executes postcondition is something which must be true after some code executes invariant is bot
by rcxdude 3y ago
precondition is something which must be true before some code executes
postcondition is something which must be true after some code executes
invariant is both: something which must be true both before and after some code executes.
So it's the other way around. An invariant is a postcondition, but a postcondition is not necessarily an invariant.
(you can check all three with assertions, but they will generally exist whether you check them or not)
- _a_a_a_ 3y agoA reasonable distinction. I accept it.