1
我正在使用multimethods來解析命令行命令及其參數。如何在clojure中設置和獲取多方法元數據?
(defmulti run (fn [command args] command))
(defmethod run :default
[& _]
...)
^{:args "[command]"}
(defmethod run "help"
[_ & [args]]
"Display command list or help for a given command"
...)
^{:args ""}
(defmethod run "version"
[_ & [args]]
"Print program's version"
...)
(defn -main
[& args]
(run (first args)
(next args)))
當我試圖訪問元數據,具體的方法,Clojure的返回nil
:
(meta ((methods run) "help"))