remove-method

clojure.core

  • (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)
    nil
    user=> (defn line [p1 p2] {:Ob :line :p1 p1 :p2 p2})
    #'user/line
    user=> (defn circle [cent rad] {:Ob :circle :cent cent :rad rad})
    #'user/circle
    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/cc
    user=> (def ll (line [1 1][0 0]))
    #'user/ll
    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)
    user=>
    
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:1622 top

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

Comments top

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