Skip to content

Instantly share code, notes, and snippets.

@espeed
Created April 17, 2012 03:48
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 espeed/2403336 to your computer and use it in GitHub Desktop.
Save espeed/2403336 to your computer and use it in GitHub Desktop.
Multimethod Not Working
;; Trying to use type hinting to differentiate between two single-arg methods,
;; but I suspect I'm doing it totally wrong
(defmulti add-vertex (fn [& args] (map class args)))
(defmethod add-vertex [] (add-vertex nil nil))
(defmethod add-vertex Integer [id] (add-vertex id nil))
(defmethod add-vertex Map [props] (add-vertex nil props))
(defmethod add-vertex [Integer Map] [id props]
((let [vertex (. *g* addVertex id)]
(when props
(apply set-property! vertex (interleave (map name (keys props)) (vals props))))
vertex)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment