medley
medley copied to clipboard
Add ?? macro. It's like `clojure.core/or` but for nil's.
Thank you for the patch, but I think this is too specific for Medley.
@darkleaf Not sure what your use case is but have you considered:
(m/find-first some? ...)
If I'm reading your test cases correctly I think the only case the above doesn't cover is:
(is (= :ok (m/?? :ok (throw (ex-info "Fail" {})))))`
@anthonygalea I want to use ??
to set up lazy defaults:
(fn [x y z]
(m/?? x (costly-get-x y z) (throw (ex-info "Can't get x" {:y y, :z z}))))
(fn [x y z]
(m/?? x (costly-get-x y z) default-value))
(m/?? (get-in x [...])
(my-func ...)
(get-in y [...])
(throw ...))