f1a9xa
Last Updated: February 25, 2016
·
4.382K
· runexec
81609937c20aeab3598aea56f1f4f022

Slurp vs Reader in Clojure

What is slurp?

slurp is technically a fully realized result of a clojure.java.io/reader.

When should I use slurp?

When memory is not a concern.

example

(slurp "http://www.coderwall.com/runexec")

What is reader?

reader will attempt to convert its argument to a BufferedReader.

When should I use reader

When a lazy sequence of the results are needed or to create a new BufferedReader.

example

(with-open [rdr (clojure.java.io/reader 
               "http://www.coderwall.com/runexec")]
         (clojure.string/join "\n" (line-seq rdr)))
Say Thanks
Respond