Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created September 15, 2011 19:31
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 swannodette/1220237 to your computer and use it in GitHub Desktop.
Save swannodette/1220237 to your computer and use it in GitHub Desktop.
ex.clj
(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