On Mon, Sep 5, 2016 at 9:25 AM, hiskennyness <kentil...@gmail.com> wrote:
> > In other languages you might see: > > (defn himom [] ..) > (defn himom [x] ...) > (defn himom [x y z] ...) > > > Come to think of it, maybe Clojure does that, too, (nooby myself) but the > Clojure syntax for overloading I know puts each definition under the same > defn, wrapping each in parens): > > (defn himom > ([] ..) > ([x] ...) > ([x y z] ...)) > > FYI, what actually happens in Clojure if you attempt the first kind of code is that function himem will be defined once, then redefined twice, ending by being a function that takes 3 arguments only. If you want a function that takes multiple different arities, you must use either the latter way of defining it, or if you want 'n or more arguments', the syntax (defn himom [required-arg1 required-arg2 & optional-args] ...) Andy -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.