0

Syntax error when passing Java static method to Clojure function args directly:

(filter Character/isUpperCase "aBcD")

Why does it want the wrapper then work?

(filter #(Character/isUpperCase %) "aBcD")
sof
  • 9,113
  • 16
  • 57
  • 83

1 Answers1

1

Because filter takes a Clojure function as first argument, and one or more collections as rest.

A Java method is not a Clojure function. Wrapping the method in an anonymous function makes it one.

NielsK
  • 6,886
  • 1
  • 24
  • 46