Consider the following Clojure code:
(defn space? [c] (Character/isWhitespace c))
It's okay. But obviously, this is just another name and refactor in pointless style:
(def space? Character/isWhitespace)
But I get compilation error:
Caused by: java.lang.RuntimeException: Unable to find static field: isWhitespace
in class java.lang.Character
Why it can't find it? It works perfectly with Clojure functions:
(def wrap-space? space?) ; Compiles OK!
What happens here? Why def with Java static function doesn't work?
def, you would have to use an anonymous function:(def space? #(Character/isWhitespace? %)).