How do I write static blocks in Xtend?

66 views Asked by At

Just like in Java:

static {

}

What should I do?

1

There are 1 answers

0
Mureinik On BEST ANSWER

Extend currently doesn't support static initializers - see https://bugs.eclipse.org/bugs/show_bug.cgi?id=429141.

One possible workaround is to create a field you don't care about just for the side-effects of the initializer:

static val I_AM_ONLY_FOR_SIDE_EFFECTS = {
  // Code you'd want in your static initializer
  return 0
}