3 ms·
> Contracts? how they're different or less verbose than plain asserts? what they do better? The difference to asserts is that they express a property over to p
by funcDropShadow 4y ago
> Contracts? how they're different or less verbose than plain asserts? what they do better?
The difference to asserts is that they express a property over to points in the execution of a program, whereas an assert only states a property of one point in the execution in the program. Practically, that means that you can refer to the state before some code in addition to the state after in the post-condition of that code.
- mrkeen 4y agoThis reminds me of @NotNull/@NonNull annotations in Java. Those annotations may trigger, depending on how the method is called. Then there's just a plain old notNull() static method, which will trigger.