Skip to content

Instantly share code, notes, and snippets.

@wjdix
Forked from ideal-knee/better-if-let.clj
Last active August 29, 2015 14:06
Show Gist options
  • Save wjdix/b248107453e2f63edd38 to your computer and use it in GitHub Desktop.
Save wjdix/b248107453e2f63edd38 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