Hi,

I try to define multi-methods but when I call one I get an exception.

I declared the multi-methods like below:

(defmulti new-food-item (fn [food expiration]
                          (if (number? expiration)
                            ::duration
                            ::expiration-date)))

(defmethod new-food-item ::duration [food expiration-duration]
  (let [expiration-date (GregorianCalendar.)]
    (.add expiration-date GregorianCalendar/DAY_OF_MONTH 
expiration-duration)
    {:name food :expiration-date expiration-date}))

(defmethod new-food-item ::expiration-date [food expiration-date]
  {:name food :expiration-date expiration-date})


And when I do: (new-food-item "tomatoes" 5)
I get this exception:
ArityException Wrong number of args (2) passed to: core$class 
 clojure.lang.AFn.throwArity (AFn.java:437)

I don't understand where is the problem :/

Some help?

Thank you.

Chris

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

Reply via email to