Contents    Page-10    Prev    Next    Page+10    Index   

println, do, when, str

The println function prints its arguments:


(let [n 3] (println "n = " n))
    ->  n =  3

The do form wraps multiple forms and executes them in order, similar to { ... } in C-like languages. Use do when printing, since printing is a side-effecting operation. The value of do is the value of the last form.

when is like a combination of if and a do in the true branch (with no false branch):


(when (> 5 3)
  (println "Whew!")
  (println "I'd be worried otherwise."))

str makes a string from the values of its arguments.


user=>(str 3 " and " '(a b))
"3 and (a b)"