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
  • 8,243
  • 15
  • 49
  • 78

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,778
  • 1
  • 23
  • 46