Groovy web console

subscribe to the feed Subscribe
to this
site

Delegate property overwrite method

Published 3 months ago by Felix Scheinost
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
class Base {
  String getString() {
    "foo"
  }
}

class Impl extends Base {
  String string = "bar"
}

class Delegating {
  @Delegate
  Impl sub = new Impl()
}

assert new Delegating().string == "bar"