gpt4 book ai didi

clojure - defprotocol "no single method"错误似乎是 Leiningen 中的一个错误

转载 作者:行者123 更新时间:2023-12-02 15:47:49 25 4
gpt4 key购买 nike

我正在学习 Clojure 中的协议(protocol),并且在以下代码中遇到了此错误:

CompilerException java.lang.IllegalArgumentException:没有找到接口(interface):gangnam.core.Legi 的单一方法:valores_BANG_ 函数:valores!协议(protocol):Legi,编译:(NO_SOURCE_PATH:1:1)

一切都运行得很好,直到我尝试向协议(protocol)添加七个以上的方法(下面的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)))

最佳答案

lein clean 应该可以为您解决这个问题。

关于clojure - defprotocol "no single method"错误似乎是 Leiningen 中的一个错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19434311/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com