(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)cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |