3 ms·
Here's another example showing how you can use the :fn spec to relate the :args and :ret values in arbitrary ways. (defn title-case "Capitalizes the firs
by puredanger 10y ago
Here's another example showing how you can use the :fn spec to relate the :args and :ret values in arbitrary ways.
(defn title-case
"Capitalizes the first letter of each word"
[s]
(str/replace s #"(\w+)" (comp str/capitalize second)))
(title-case "moving pictures") ;; => "Moving Pictures"
(spec/fdef title-case
:args (spec/cat :s string?)
:ret string?
:fn #(= (-> % :args :s str/capitalize) (-> % :ret str/capitalize)))