01 Apr 2014, 10:15
Generic-user-small

Nathanael Rumapea (1 post)

i’m currently new in clojure and when i try to learn from this book, i got error when making the save-message function (chapter 1 page 17)

did something wrong with my code ?

(defroutes home-routes (GET “/” [] (home)) (POST “/” [name message] (save-message name message)))

(defn save-message [name message] (cond

(empty? name) (home name message “no name”)

(empty? message) (home name message “no comment”)

:else (do (println name message) (home))))

15 Apr 2014, 02:54
Person_photo_pragsmall

Bruno Kim Medeiros Cesar (4 posts)

Nathanael, you must declare save-message before defroutes. Alternatively, you can use declare to forward a declaration.

(declare save-message)

(defroutes …)

(defn save-message …)

  You must be logged in to comment