2

If a certain Java class has a method called "eval", how can I call it from Clojure?

Doing the following seems to call the eval method from the clojure.core instead of TestObject's eval:

(defn test[x] 
  (let [obj (new TestObject)] 
    (. obj eval x)))
1
  • That does not seem to be true - what makes you think that? Commented Feb 18, 2013 at 1:40

1 Answer 1

2
(defn test[x] 
  (let [obj (new TestObject)] 
    (.eval obj x)))

Edit. However it's very strange. The Dot special form . expects a symbol as second parameter and the name of this symbol is interpreted as a name of class method/field. So eval can't be evaluated to eval function in your case.

Sign up to request clarification or add additional context in comments.

1 Comment

@EmreColak Does it eliminate the problem?

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.