in the :constructors map and subsequent -init definitions, how do I represent a varargs constructor (assuming the superclass has multiple constructors of which one is varargs) ?
clojure gen-class varargs constructor
1.1k views Asked by Hendekagon At
2
There are 2 answers
0
On
Since clojure don't support it at the moment you need to patch it with: https://groups.google.com/forum/#!topic/clojure/HMpMavh0WxA.
And use it with new meta tag:
(ns t.vtest
(:gen-class
:implements [clojure.lang.IDeref]
:init init
:state state
:constructors {^:varargs ["[Ljava.lang.Object;"] []}
))
Since varargs are essentially syntax sugar for Object arrays, you could just use "[Ljava.lang.Object;" as the type of constructor's parameter.
Here's some sample code:
and that's how it looks in REPL