Created
July 19, 2011 03:28
-
-
Save swannodette/1091247 to your computer and use it in GitHub Desktop.
multi.clj
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
(defmulti foo (fn [x y] (into #{} [x y]))) | |
(defmethod foo #{::a ::b} | |
[x y] "We found ::a ::b") | |
(defmethod foo #{::c ::d} | |
[x y] "We found ::c ::d") | |
(comment | |
(foo ::b ::a) ;; "We found ::a ::b" | |
(foo ::d ::c) ;; "We found ::c ::d" | |
) | |
(defmulti bar (fn [x y] [x y])) | |
(defmethod bar [::car ::car] | |
[x y] "2 cars") | |
(derive ::porsche ::car) | |
(derive ::delorean ::car) | |
(comment | |
(bar ::porsche ::delorean) ;; "2 cars" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment