Created
September 15, 2011 19:31
-
-
Save swannodette/1220237 to your computer and use it in GitHub Desktop.
ex.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
(defrecord Place [name]) | |
(defrecord HappyPlace [name]) | |
(defmulti say-hello type) | |
(defmulti location type) | |
(defmethod say-hello :default | |
[this] (str "Hello" (location this))) | |
(defmethod location :default | |
[this] (str (:name this))) | |
(defmethod say-hello Place | |
[this] (str "Hello" (location this))) | |
(defmethod say-hello HappyPlace | |
[this] (str "HELLO " (location this) "!")) | |
(comment | |
(say-hello (Place. "World")) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment