Skip to content

Instantly share code, notes, and snippets.

@rrichardson
Created December 8, 2013 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rrichardson/7863716 to your computer and use it in GitHub Desktop.
Save rrichardson/7863716 to your computer and use it in GitHub Desktop.
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: " (clojure.string/upper-case (:message msg))))
#<MultiFn clojure.lang.MultiFn@4706c7b2>
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