4

我正在学习 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)

在我尝试向协议中添加七种以上的方法之前,一切都运行良好(valores!如下)。所以我复制valoresvalores!以确保我使用的是相同的代码,除了!最后,它不起作用。我还尝试将其换成不同的名称 ( 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)))
4

1 回答 1

2

lein clean应该为你解决这个问题。

于 2013-12-15T12:35:36.670 回答