|
|
|
|
|
by irrelative
5406 days ago
|
|
I feel a little bit crazy because no one else has brought this up yet, but what's the point of declaring types if your errors don't get caught at compile time? If they're going to throw errors at runtime, how is that an improvement over not checking the types? |
|
But we would still like to express and enforce some invariants about our code. And we'd like to do it in a more elegant way than constantly writing "if(argument === ...) then ... else ..."
Contracts also allow us to check invariants that might not result in a run-time exception but could lead to the code just being subtly wrong.