Skip to content

Instantly share code, notes, and snippets.

/gist:7863679
Created Dec 8, 2013

Embed
What would you like to do?
webbitchat.core=> (defmulti send-multi (fn [msg] (-> msg :action keyword)))
nil
webbitchat.core=> send-multi
#<MultiFn clojure.lang.MultiFn@4706c7b2>
webbitchat.core=> (defmethod send-multi :SAY [msg] (println "I just called to say: " (:message msg)))
#<MultiFn clojure.lang.MultiFn@4706c7b2>
webbitchat.core=> (defmethod send-multi :YELL [msg] (println "I JUST CALLED TO YELL: " (map upper-case (:message msg))))
webbitchat.core=> (send-multi {:message "I love you" :action "SAY"})
ArityException Wrong number of args (1) passed to: core$fn--666$fn clojure.lang.AFn.throwArity (AFn.java:437)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.