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?

Zoe
  • 27,060
  • 21
  • 118
  • 148
koszti
  • 131
  • 1
  • 8

1 Answers1

1

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

(Expression. "1+2" (into-array PrimitiveElement []))
Zoe
  • 27,060
  • 21
  • 118
  • 148
koszti
  • 131
  • 1
  • 8