2
我想在一个单独的文件中定义multimethod及其实现。它是这样的: 在文件1在不同命名空间的单独文件中实现multimethod
(ns thing.a.b)
(defn dispatch-fn [x] x)
(defmulti foo dispatch-fn)
在文件2
(ns thing.a.b.c
(:require [thing.a.b :refer [foo]])
(defmethod foo "hello" [s] s)
(defmethod foo "goodbye" [s] "TATA")
,并在主文件,当我调用该方法,我定义是这样的:
(ns thing.a.e
(:require thing.a.b :as test))
.
.
.
(test/foo "hello")
当我这样做时,我得到一个异常说"No method in multimethod 'foo'for dispatch value: hello
我在做什么错了?或者是不可能在单独的文件中定义multimethods的实现?