Liking cljdoc? Tell your friends :D
Clojure only.

hara.class.multi


multimethodclj

(multimethod source name)

creates a multimethod from an existing one

(defmulti hello :type)

(defmethod hello :a [e] (assoc e :a 1))

(def world (multimethod hello "world"))

(defmethod world :b [e] (assoc e :b 2))

(world {:type :b}) => {:type :b :b 2}

;; original method should not be changed (hello {:type :b}) => (throws)

creates a multimethod from an existing one

(defmulti hello :type)

(defmethod hello :a
  [e] (assoc e :a 1))

(def world (multimethod hello "world"))

(defmethod world :b
  [e] (assoc e :b 2))

(world {:type :b})
=> {:type :b :b 2} 

;; original method should not be changed
(hello {:type :b})
=> (throws)
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close