I study Clojure, and still I can not understand this little riddle, which, I am sure, is a ridiculous base.
I have this file:
(ns cloapp.core (:gen-class)) (defn -main "I don't do a whole lot ... yet." [& args] (println "Hello, World!") (println "Well Hi there, im a string !") (println "Why wont this work !") (myFunc "Hiya")) (defn myFunc [aVar] (println aVar))
If I try to run this with
lein run
He complains and says:
Caused by: java.lang.RuntimeException: Unable to resolve symbol: myFunc in this context
But if I remove the call to myFunc from main and do,
lein repl cloapp.core=> (myFunc "Hiya !") Hiya ! nil cloapp.core=>
Then I can call it. Why is this? I guess this has something to do with the namespace, but reading it I can't solve it.
A
source share