New
- #112: Add
binding
,with-out-str
andwith-in-str
:
$ ./bb '(let [w (java.io.StringWriter.)] (binding [*out* w] (println "hello")) (str w))'
"hello\n"
$ ./bb "(count (with-out-str (println \"hello\")))"
6
$ ./bb '(with-in-str "hi" (read-line))'
"hi"
Notes:
- Currently
binding
only works withclojure.core/*in*
andclojure.core/*out*
*in*
has a special meaning in babashka expressions, but you can refer to Clojure's*in*
by fully qualifying it:clojure.core/*in*
.