Mah*_*dam 2 clojure runtimeexception
从lein run执行此功能时,程序按预期执行.但我正在尝试使用atom.io的proto-repl包,当我使用proto-repl调用该函数时,它会给出一个"CompilerException java.lang.RuntimeException:无法解析符号:在这种情况下可以投票".这是我的功能:
(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")))
Run Code Online (Sandbox Code Playgroud)
Jos*_*osh 11
当您的repl启动时,它可能会将您置于user命名空间中.您需要移动到clojure-noob.core命名空间或使用完全限定符号调用它.
如果要切换名称空间
(ns clojure-noob.core) ;; switch to the correct namespace
(can-vote) ;; call the function
Run Code Online (Sandbox Code Playgroud)
如果要使用用户命名空间中的完全限定符号来调用它
(require 'clojure-noob.core) ;; first require the namespace
(clojure-noob.core/can-vote) ;; call the fully qualified function
Run Code Online (Sandbox Code Playgroud)
您可以在此处阅读有关命名空间和从其他命名空间和库调用函数的更多信息.
| 归档时间: |
|
| 查看次数: |
5630 次 |
| 最近记录: |