I'm trying to learn clojure, but coming from OO background simple things look like mission impossible. For instance, how do I write the function that would accept console input and output it into console as well?
I'm trying something like this, but it doesn't work.
(ns ClojureTest2.core)
,(defn fun []
(let [input (read-line)])
(println input)
)
(fun [])
P.S. I work with eclipse - counterclockwise
Try this:
(ns ClojureTest2.core)
(defn fun []
(let [input (read-line)]
(println input)))
(fun)
Note how the println
is enclosed in the let
statement. input
will only exist within the let
statement. Also, the empty parameter list of fun
means you do not need to supply any arguments to call it.