> yes there is a way: http://clojure.org/multimethods

And also plain ol' arity overriding:

(defn foo
   "Do something."
   ([x] (println x))
   ([x y] (println (+ x y))))


For something similar to Java, where a particular method is selected  
purely on the type of the arguments, a multimethod like this will do  
the same:


(defmulti foo (fn [& args] (vec (map type args))))

(defmethod foo [String Integer] [x y]
   (println "Got string and int"))

(defmethod foo [String String] [x y]
   (println "Got two strings"))

(foo "bar" "baz")
(foo "bar" 5)


-R

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to