Wednesday, December 16, 2015

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 RSS · Twitter

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

Leave a Comment