The following code is not allowed:
public static var steps(default, setSteps):Int = 1;
Is it possible to do this without a static constructor (__init__ if I’m correct)?
In particular I simply want steps to be a publicly readable variable,
it should also be publicly writeable, but only positive values are allowed.
The setSteps function which will enforce this constraint.
What is the cleanest (most compact) way to do this?
I don’t have the last release version of haxe, but in nightly build version this code is allowed and works as expected.
However, if you version of haxe really does not support such initialization, then using init is the only right way(and most compact at the same time) to do what you want.