Difference / relationship between str and print-str in Clojure

I read the Volkmann Clojure tutorial , this tutorial says that the print-str function prints the contents to the returned string. Does this mean that:

(print-str abc ... ) == (str a " " b " " c " " ... )

I tried with my REPL and it behaved as I expected above, but I just want to know if this is really true, or I am missing something here ...

+4
source share
1 answer

The print-str function will return a string similar to the one that REPL will report if asked to evaluate the argument, for example. for human consumption. The str function calls the object's .toString object. In the case of a string argument, the result will be the same as you specify.

This does not apply to other objects at all.

  ((juxt print-str str) 1N) ;=> ["1N" "1"] ((juxt print-str str) (java.util.Date.)) ;=> ["#inst \"2013-07-19T01:47:00.784-00:00\"" "Thu Jul 18 20:47:00 CDT 2013"] 
+5
source

Source: https://habr.com/ru/post/1492200/


All Articles