我正在学习Clojure中的协议,我遇到了以下代码的错误:
CompilerException java.lang.IllegalArgumentException: No single method: valores_BANG_ of interface: gangnam.core.Legi found for function: valores! of protocol: Legi, compiling:(NO_SOURCE_PATH:1:1)
在尝试向协议添加7个+方法之前,所有内容都非常有效(valores!
)。因此,我将valores
复制到valores!
以确保我使用相同的代码,但最后的!
除外,它无法正常工作。我也尝试将其换成另一个名称(dele
)。
然后我记得我最近运行lein install
并且当我再次运行lein install
时,似乎解决了这个问题。知道为什么会这样吗?
(defprotocol Legi
(lege [self] [self key])
(carpe! [self] [self key] [self key val])
(muta!* [self key val])
(juga! [from label to])
(claves [self])
(valores [self])
(valores! [self]))
(extend-protocol Legi
Iterable
(lege
([self]
(for [elm self]
(lege elm)))
([self key]
(for [elm self]
(lege elm key))))
(carpe!
([self]
(for [elm self]
(carpe! elm)))
([self key]
(for [elm self]
(carpe! elm key)))
([self key val]
(for [elm self]
(carpe! elm key val))))
(muta!*
[self key val]
(doall (for [elm self]
(muta!* elm key val))))
(juga! [from label to]
(for [elm from]
(juga! elm label to)))
(claves [self]
(for [elm self]
(claves elm)))
(valores [self]
(for [elm self]
(valores elm)))
(valores! [self]
(for [elm self]
(valores elm)))
Element
(lege
([self]
(into {} (for [k (.getPropertyKeys self)]
[(keyword k) (lege self k)])))
([self key]
(-> self (.getProperty (name key)))))
(carpe!
([self]
(for [k (.getPropertyKeys self)]
(carpe! self k)))
([self key]
(let [prop (lege self key)]
(res
(-> self (.removeProperty (name key))))
prop))
([self key val]
(let [prop (lege self key)]
(if (= val prop)
(carpe! self key)))))
(muta!* [self key val]
(res
(let [key (name key)]
(.setProperty self key val)
self)))
(juga! [from label to]
(when (and from to)
(res
(.addEdge *g*
nil from to (name label)))))
(claves [self]
(-> self .getPropertyKeys))
(valores [self]
(-> self lege vals))
(valores! [self]
(-> self lege vals)))
答案 0 :(得分:2)
lein clean
应该为您解决此问题。