You're viewing version 1.2.0 of remove-method. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16



  • (remove-method multifn dispatch-val)
Removes the method of multimethod associated with dispatch-value.

1 Example top

  • ;; long example showing setting up a multi-method, then removing one of the 
    ;; methods, showing the multi-method has been removed
    user=> (defmulti tos :Ob)
    user=> (defn line [p1 p2] {:Ob :line :p1 p1 :p2 p2})
    user=> (defn circle [cent rad] {:Ob :circle :cent cent :rad rad})
    user=> (defmethod tos :line [l] (str "Line:" (l :p1) (l :p2)))
    #<MultiFn clojure.lang.MultiFn@73aecc3a>
    user=> (defmethod tos :circle [c] (str "Circle:" (c :cent) (c :rad)))
    #<MultiFn clojure.lang.MultiFn@73aecc3a>
    user=> (def cc (circle [2 3] 3.3))
    user=> (def ll (line [1 1][0 0]))
    user=> (tos cc)
    "Circle:[2 3]3.3"
    user=> (tos ll)
    "Line:[1 1][0 0]"
    user=> (remove-method tos :line)
    #<MultiFn clojure.lang.MultiFn@73aecc3a>
    user=> (tos ll)
    java.lang.IllegalArgumentException: No method in multimethod 'tos' for dispatch
    value: :line (NO_SOURCE_FILE:0)
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:1364 top

(defn remove-method
  "Removes the method of multimethod associated with dispatch-value."
  {:added "1.0"}
 [^clojure.lang.MultiFn multifn dispatch-val]
 (. multifn removeMethod dispatch-val))
Vars in clojure.core/remove-method: defn
Used in 0 other vars

Comments top

No comments for remove-method. Log in to add a comment.