Skip to content

Instantly share code, notes, and snippets.

@rcanepa
Created December 15, 2015 14:57
Show Gist options
  • Save rcanepa/d0d91d08634b02c84b79 to your computer and use it in GitHub Desktop.
Save rcanepa/d0d91d08634b02c84b79 to your computer and use it in GitHub Desktop.
Improve feedback from Clojure function pre/post conditions.
(defn string-to-string [s1]
{:pre [(or (string? s1)
(throw (Exception. (format "Pre-condition failed; %s is not a string." s1))))]
:post [(or (string? %)
(throw (Exception. (format "Post-condition failed; %s is not a string." %))))]}
s1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment