Clojure read function issue

I try to get console input in my Clojure program, but when it gives me this error, when it gets to that part of the program.

Exception in thread "main" java.lang.ClassCastException:
clojure.lang.LineNumberingPushbackReader cannot be cast to java.io.BufferedReader

The read function works, but that’s not what I need. Here is the code I'm using.

(defn prompt-read [prompt]
  (print (format "%s: " prompt))
  (flush )
  (read-line))

EDIT:

This is obviously the only version I'm using. This is the version included in the current Clojure programming code example, I will post the current release version and see if this is a problem.

+5
source share
2 answers

Hmm, it seems to work for me. What version of Clojure are you using and how do you invoke the invitation? Here is what I am returning (here goois my answer):

user=> (defn prompt-read [prompt]
(print (format "%s: " prompt))
(flush )
(read-line))
#'user/prompt-read
user=> (prompt-read "foo")
foo: goo
"goo"
+3
source

. . Clojure.

+1

All Articles