6

I use a java library in clojure and it has a function that accepts a callback:

http://home.dv8tion.net:8080/job/JDA/Promoted%20Build/javadoc/net/dv8tion/jda/entities/MessageChannel.html#sendMessageAsync-java.lang.String-java.util.function.Consumer-

How do I pass such callback in clojure? I tried anonymous function fn but it doesn't work. In java using java lambdas works.

1
  • hyperlink is broken Commented Apr 11, 2017 at 15:32

1 Answer 1

10

You can simply reify an interface.

Here is an example

(def consumer (reify java.util.function.Consumer
                (accept [this t]
                  ; here the impl 
                  )))
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.