Wednesday, December 16, 2015 [Tweets] [Favorites]

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.

1 Comment

[…] Update (2017-03-15): Previously: precondition vs. assert in Swift. […]

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment