News for hackers. Stuff that matters.
Re:Inheritance versus Composition by cinnamonheart on Thursday May 09, 2019 @08:32AM (#19867659)
Dotty (Scala 3) recently added support for forwarding to a contained object via an 'export' keyword.

  class A {
    def foo(): String = ...
    def bar(): String = ...
    def baz(): String = ...
  }

  class B {
    private val a: A = new A()
    def foo(): String = ...

    // Export a's methods as b's, except for foo, and rename baz as qux
    export a.{foo => _, baz => qux, _}
  }

  val b = new B()
  b.foo() // b's implementation
  b.bar() // a's
  b.qux() // a's baz

There are no comments on this comment yet.