Is str's behavior changed?

77 views
Skip to first unread message

Alice

unread,
Jan 14, 2018, 11:26:45 PM1/14/18
to Clojure
Unlike explained in http://blog.klipse.tech/clojure/2016/11/24/stringify-clojure.html (str "Hello\nWorld") just prints "Hello\nWorld"(Surrounding quotes are preserved and new lines are not interpreted). String.toString() just returns the string itself, so I have no idea why it should be the way explained in the post in the first place.

James Reeves

unread,
Jan 14, 2018, 11:42:28 PM1/14/18
to clo...@googlegroups.com
The str function has always behaved in the same way. The article is somewhat misleading.

The article does say "strings print without the surrounding quotes", which is true if you're using the function "print" or "println":

  user=> (println "Hello World")
  Hello World
  nil

But REPLs print the representation of the evaluated expression. They use "pr" instead of "print" and "prn" instead of "println":

  user=> (prn "Hello World")
  "Hello World"
  nil

  user=> "Hello World"
  "Hello World"


On 15 January 2018 at 04:26, Alice <doff...@gmail.com> wrote:
Unlike explained in http://blog.klipse.tech/clojure/2016/11/24/stringify-clojure.html (str "Hello\nWorld") just prints "Hello\nWorld"(Surrounding quotes are preserved and new lines are not interpreted). String.toString() just returns the string itself, so I have no idea why it should be the way explained in the post in the first place.

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
James Reeves
Reply all
Reply to author
Forward
0 new messages