precondition vs. assert in Swift
Erica Sadun quotes Dave Abrahams:
The two functions have distinct roles:
- assert: checking your own code for internal errors.
- precondition: for checking that your clients have given you valid arguments.
It’s actually important to distinguish these two cases because the second one demands public documentation while the first does not.
Comments
Stay up-to-date by subscribing to the Comments RSS Feed for this post.