Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- boot.user=> (binding [*out* (java.io.StringWriter.)] (println "hello") (str *out*))
- "hello\r\n"
- boot.user=> (source with-out-str)
- (defmacro with-out-str
- "Evaluates exprs in a context in which *out* is bound to a fresh
- StringWriter. Returns the string created by any nested printing
- calls."
- {:added "1.0"}
- [& body]
- `(let [s# (new java.io.StringWriter)]
- (binding [*out* s#]
- ~@body
- (str s#))))
- nil
- boot.user=> (with-out-str (println "hello"))
- "hello\r\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement