tags:

views:

143

answers:

1

I'm learning how to extend Java classes in Clojure, but I don't see a way declare new member variables; I only see a way for methods.

(ns test.aclass
  (:gen-class
    :methods [[foo [] String]]))

Is there a :members keyword or another way of declaring member variables?

+4  A: 

:state name

If supplied, a public final instance field with the given name will be created. You must supply an :init function in order to provide a value for the state. Note that, though final, the state can be a ref or agent, supporting the creation of Java objects with transactional or asynchronous mutation semantics.

There is an example on the website of how it can be used.

Timothy Pratley