0
Clojure에서 multimethod를 예상대로 작동 시키는데 어려움을 겪고 있습니다. 내 코드의 증류는 다음과 같습니다. 하나의 첫 번째 defmethod로 보내 대신 내가 널 포인터 예외를 얻어야한다 :예기치 않은 null 포인터를주는 Clojure multimethod
(defn commandType [_ command] (:command-type command))
(defmulti testMulti commandType)
(defmethod testMulti :one [game command] (str "blah"))
(defmethod testMulti :default [& args] "Cannot understand")
(testMulti "something" {:command-type :one})
(commandType "something" {:command-type :one})
지금은 물론 수익의 것 인수에 호출 된 메소드의 CommandType을가 여기에 기대. here 잘 작동있는 Clojure의 워드 프로세서에서
(defmulti simpleMulti :key)
(defmethod simpleMulti "basic" [params] "basic value")
(simpleMulti {:key "basic"})
그리고 아직 예 : 심지어 multimethod의 간단한 호출 나는 나에게 널 포인터를 제공합니다 함께 올 수 있습니다. 내가 잘못하고있는 근본적인 것이 있습니까?
네 말이 맞아
을 감안할 때. 그들은 새로운 REPL을 시작한 후에 일했습니다. –