Created
October 16, 2009 09:38
-
-
Save hiredman/211677 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def base-car #{:four-wheels}) | |
(defmulti what-is-this identity) | |
(defmethod what-is-this #{:four-wheels} [_] (println "this is a base car")) | |
(defmethod what-is-this #{:four-wheels :mine} [_] (println "this is a base car of mine")) | |
(defmethod what-is-this #{:four-wheels :v8} [_] (println "this is a big car")) | |
(defmethod what-is-this #{:four-wheels :v8 :mine} [_] (println "this is a big car of mine")) | |
(defmethod what-is-this :default [_] (println "this is not a car")) | |
user=> (what-is-this base-car) | |
this is a base car | |
nil | |
user=> (conj base-car :mine) | |
#{:four-wheels :mine} | |
user=> (what-is-this *1) | |
this is a base car of mine | |
nil | |
user=> (conj base-car :suprise-tractor-hitch) | |
#{:four-wheels :suprise-tractor-hitch} | |
user=> (what-is-this *1) | |
this is not a car | |
nil | |
user=> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment