I hereby claim:
- I am chrisdevo on github.
- I am cdevine (https://keybase.io/cdevine) on keybase.
- I have a public key ASCvYbpoCYfH8XuuFnatt5-l9FYF0isQoP1qAfZrISrWiAo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
;; Using `assert` in :pre doesn't work because `(assert true)` returns `nil`. | |
;; :pre expects a truthy value, not `nil`. | |
;; Even though `clojure.test/is` is technically 'test' code (which usually doesn't appear in production code), | |
;; in this case it provides the behavior I want (custom error messages when validating funtion arguments) | |
;; with little overhead. | |
;; Using `assert` | |
(defn my-fn [bool] | |
{:pre [(assert bool (format "Custom message returning modified value of bool: %s" (not bool)))]} | |
(println bool)) |