1

I want to use mXparser from clojure which has an Expression Java class with multiple constructors:

  1. public Expression(PrimitiveElement...elements) { ... }
    
  2. public Expression(String expressionString, PrimitiveElement...elements) { ... }
    

In Java I can create new instance with a String argument:

Expression e = new Expression("1+2");

I assume it is using the second constructor because the first argument is string and the second is optional.

Now I want to do the same in clojure:

(Expression. "1+2")

It fails with

java.lang.String cannot be cast to [Lorg.mariuszgromada.math.mxparser.PrimitiveElement;

Looks like it is trying to use the first constructor which is not what I want.

How can I create a new instance of this class in Clojure only with a string argument?

1

1 Answer 1

1

According to the comment from glts it works in this way:

(Expression. "1+2" (into-array PrimitiveElement []))
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.