clojure的宏cond,与java 的switch case类似:
(ns guestbook.models.clojureCond)
(defn clojureCond
"cond vs switch case "
[arg]
(cond
(= arg 5)
(println "arg equal 5")
(= arg 10)
(println "arg equal 10")
:else
(println "arg is not known")
)
)
结果:
(use 'guestbook.models.clojureCond)
=> nil
(clojureCond 5)
arg equal 5
=> nil
(clojureCond 15)
arg is not known
=> nil
QQ交流群:967328440