Skip to content

Commit bc21e22

Browse files
committed
[new] Add 0-arity threadlocal
1 parent 0c5b5ad commit bc21e22

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/taoensso/encore.cljc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2466,10 +2466,11 @@
24662466
#?(:clj
24672467
(defmacro threadlocal
24682468
"Returns `java.lang.ThreadLocal` with given initial value."
2469-
[& init-val]
2470-
`(ThreadLocal/withInitial
2471-
(reify java.util.function.Supplier
2472-
(get [_this#] (do ~@init-val))))))
2469+
([ ] `(ThreadLocal.))
2470+
([& init-val]
2471+
`(ThreadLocal/withInitial
2472+
(reify java.util.function.Supplier
2473+
(get [_this#] (do ~@init-val)))))))
24732474

24742475
(comment
24752476
(let [tl:sdf (threadlocal (SimpleDateFormat. "yyyy-MM-dd"))]

0 commit comments

Comments
 (0)