3

I have seen this somewhere documented but I cannot remember where and what was the name of the function: what I am searching for is a function/macro that takes (a Java) object as an argument, executes a sequence of methods on that object and returns it. Something like that:

(<the function> obj
  (.setName obj "the name")
  (.setAmount obj42.0)
  ; ...
  (.setDescription obj "the description"))  ; returns the updated obj

1 Answer 1

5

You can use ..:

(.. obj (setName "the name") (setAmount 42.0) ... (setDescription "the description"))

If the methods do not return the target object you can use doto:

(doto obj (.setName "the name") (.setAmount 42.0) ... (.setDescription "the description"))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.