How do you use defmulti to create a function with a variable number of args?

For example, add-item is wrapping a Java method that can take a variable 
number of args, and so here I am trying to make add-item take zero, one, or 
two args. Notice there are two singe-arg funcs -- each taking a different 
type...

(defmulti add-item class)
(defmethod add-item [] (add-item nil nil))
(defmethod add-item Integer [id] (add-item id nil))
(defmethod add-item Map [props] (add-item nil props))
(defmethod add-item :default [id props] (  ; call some Java method )

Unless I am overlooking something, I don't see anything on the Multimethods 
page (http://clojure.org/multimethods) about defmulti or defmethod taking 
a variable number of arguments -- they all take the same number of 
arguments of different types.

- James

-- 
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