Method Values

Method Values

http://insideclojure.org/2024/02/12/method-values/

Clojure 1.12.0-alpha6 introduced method values to Clojure and this post will explore them in a bit more depth. The olden days Clojure functions are first-class values and can easily be passed around, but a common question seen in Clojure forums...

#clojure #clj #cljs !clojure@lemmy.ml @clojure

6 points · 1 comments · view on lemmy.world

1 Comments

fancyl@lemmy.world · 1 pts · 2y

This is exciting! I'll keep this in my back pocket next time I need to map a static Java method over a collection.

Does this addition also make it possible to keep a Java instance method in a map to call later? That's not a good way to explain it. But I'm thinking of how Malli schemas can have a map of options like {:encode/json name}.

With this addition, could I do {:encode/json .toString} where previously I'd need to wrap it with an anonymous function?