Skip to content

Instantly share code, notes, and snippets.

@fogus
Created September 14, 2010 15:59
Show Gist options
  • Save fogus/579267 to your computer and use it in GitHub Desktop.
Save fogus/579267 to your computer and use it in GitHub Desktop.
(defmulti foo type)
(defmethod foo String [_] (println "a string"))
(defmethod foo ::cereal [_] (println "some cereal"))
(foo "blah")
; a string
(foo {:a 1})
; java.lang.IllegalArgumentException: No method in multimethod 'foo' for dispatch value: class clojure.lang.PersistentArrayMap
(foo ^{:type ::cereal} {:a 1})
; some cereal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment