Is it possible to have more complex static anonymous objects inside classes?

Hello.
I want to have structures such as these:

static var constants = {
	x : 20,
	y : TheClass.constants.x + 30
}

As far as I am concerned, I can’t do this.
One solution is to have a separate class with non-static fields, and then have a static object of that class in my main class, but this defies the purpose as it’s too complicated.

Any ideas?
Thank you!

You can make use of the fact that everything is an expression in Haxe, specifically:

Even blocks are just expressions, returning value of the last of their expressions:

static var constants = {
    var x = 20;
    var y = x + 30;
    {x: x, y: y};
}
2 Likes

Thank you!
Very helpful!