On Apr 22, 10:24 pm, mifrai <
mif...@hotmail.com> wrote:
> Is this expected behavior?
>
> (defmulti arg-count (fn [& args] (count args)))
> (defmethod arg-count 0
> ([] "zero args"))
> (defmethod arg-count 1
> ([a] "one arg"))
> (defmethod arg-count 2
> ([a b] "two args"))
> (defmethod arg-count :default
> ([& r] "a lot of args"))
>
> user> (arg-count 1)
> "one arg"
> user> (arg-count 1 2)
> "two args"
> user> (arg-count 1 2 3)
> "a lot of args"
> user> (arg-count)
Thinking that one would need something to dispatch on, I had
disallowed no-arg multimethods, but this arity-based dispatching is
fair game, so I've enabled it.
Thanks for the report,
Rich