When executing this function from lein run, the program executes as expected. But I am trying out atom.io's proto-repl package and when I call the function using the proto-repl, it gives a "CompilerException java.lang.RuntimeException: Unable to resolve symbol: can-vote in this context." Here is my function:
(defn can-vote
[]
(println "Enter age: ")
(let [age (read-line)]
(let [new-age (read-string age)]
(if (< new-age 18) (println "Not old enough")))
(println "Yay! You can vote")))
When your repl starts, it likely puts you in the user
namespace. You either need to move to your clojure-noob.core
namespace or call it with the fully qualified symbol.
If you want to switch namespaces
(ns clojure-noob.core) ;; switch to the correct namespace
(can-vote) ;; call the function
If you want to call it with the fully qualified symbol from the user namespace
(require 'clojure-noob.core) ;; first require the namespace
(clojure-noob.core/can-vote) ;; call the fully qualified function
You can read much more about namespaces and calling functions from other namespaces and libraries here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With