Skip to content

Instantly share code, notes, and snippets.

@egbulmer
Created April 3, 2015 01:31
Show Gist options
  • Select an option

  • Save egbulmer/5beb9058460b49a7006a to your computer and use it in GitHub Desktop.

Select an option

Save egbulmer/5beb9058460b49a7006a to your computer and use it in GitHub Desktop.
Strange behaviour of function vars in the case macro
(defn foo [] (print "foo!"))
(defn bar [] (print "bar!"))
(defn print-foo [fb]
(apply (case fb
:foo #'foo
:bar #'bar) []))
; Will throw this error when defined:
; SyntaxError: Unexpected token return
; You can resolve it by removing the #' from foo and bar.
; This also works:
(defn print-foo [fb]
(let [foo-map {:foo #'foo :bar #'bar}]
(apply (get foo-map fb) [])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment