Name

defmethod

Usage

special-form

Syntax

(defmethod name (arg*) form*)

Description

Defines a method for the multi-method name.

user 1 > (defmulti m (a b) "The m multimethod.")
it: #<Kiezel.MultiMethod>
user 2 > (defmethod m ((a (eql 'red)) (b string))
             (print-line "red string: " b))
it: #<Lambda Name="m">
user 3 > (defmethod m ((a (eql 'blue)) (b string))
             (print-line "blue string: " b))
it: #<Lambda Name="m">
user 4 > (defmethod m ((a (eql 'red)) (b number))
             (print-line "red number: " b))
it: #<Lambda Name="m">
user 5 > (defmethod m ((a (eql 'blue)) (b number))
             (print-line "blue number: " b))
it: #<Lambda Name="m">
user 6 > (m 'red "cherry")
red string: cherry
it: null
user 7 > (m 'blue "berry")
blue string: berry
it: null
user 8 > (m 'red 123)
red number: 123
it: null
user 9 > (m 'blue 456)
blue number: 456
it: null

See also

defmulti