8c0ac0862f
- Inline code is written using ``double backticks`` - Italicized text uses *asterisks* rather than `single backticks` - Function parameters are italicized rather than written as inline code
24 lines
425 B
ReStructuredText
24 lines
425 B
ReStructuredText
========
|
|
defmulti
|
|
========
|
|
|
|
.. versionadded:: 0.10.0
|
|
|
|
``defmulti`` lets you arity-overload a function by the given number of
|
|
args and/or kwargs. Inspired by Clojure's take on ``defn``.
|
|
|
|
.. code-block:: clj
|
|
|
|
=> (require hy.contrib.multi)
|
|
=> (defmulti fun
|
|
... ([a] "a")
|
|
... ([a b] "a b")
|
|
... ([a b c] "a b c"))
|
|
=> (fun 1)
|
|
"a"
|
|
=> (fun 1 2)
|
|
"a b"
|
|
=> (fun 1 2 3)
|
|
"a b c"
|
|
|