Skip to content

Instantly share code, notes, and snippets.

@ideal-knee
Created August 24, 2014 04:07
Show Gist options
  • Save ideal-knee/d651f415d8f063cdcc6d to your computer and use it in GitHub Desktop.
Save ideal-knee/d651f415d8f063cdcc6d to your computer and use it in GitHub Desktop.
(defmacro better-if-let
([bindings then]
`(better-if-let ~bindings ~then nil))
([[form tst & rest-bindings] then else]
`(let [temp# ~tst]
(if temp#
(let [~form temp#]
~(if (seq rest-bindings)
`(better-if-let ~(vec rest-bindings) ~then ~else)
then))
~else))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment