2

Just like in Java:

static {

}

What should I do?

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
ChSF
  • 23
  • 2

1 Answers1

1

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
}
Mureinik
  • 297,002
  • 52
  • 306
  • 350