Why does this anonymous function starting with println result in a NullPointerException?
Posted
by
noahz
on Stack Overflow
See other posts from Stack Overflow
or by noahz
Published on 2012-09-21T16:18:46Z
Indexed on
2012/09/24
3:37 UTC
Read the original article
Hit count: 182
clojure
I am learning about pmap
and wrote the following function:
(pmap #((println "hello from " (-> (Thread/currentThread) .getName))
(+ %1 %2))
[1 1 1] [-1 -1 -1])
When run, the result is a NullPointerException
(hello from clojure-agent-send-off-pool-4
hello from clojure-agent-send-off-pool-3
hello from clojure-agent-send-off-pool-5
NullPointerException user/eval55/fn--56 (NO_SOURCE_FILE:11)
Why is this happening? I have understood and observed the body of a fn
to be an implicit do
.
© Stack Overflow or respective owner