Skip to content

Life In Dynamic Typing

tags
Clojure

In dynamic typed language, assertions are used often to check assumption of your input data. In Clojure the :pre and :post conditions can be used effectively to fill this purpose.

(defn f [x]
  {:pre [(integer? x)]
   :post string?}
  (str x))

{:elide-asserts true} in production build compiler options to remove :pre and :post assertions in your code.

Source

See also (generated)