Documentation sources for Scala cross referencing in traits

Viewed 101

Sometime ago I saw such example of defining traits that allow the extender to choose what implementation is easier and override one of the methods:

trait Foo {
  def eq(x: Any): Boolean = !neq(x)
  def neq(x: Any): Boolean = !eq(x)
}

final class Bar extends Foo {
  override def eq(x: Any): Boolean = x.toString == "bar"
}

So here there is no full (in terms of non-looping, computationally final) implementation of the Foo, but once one of the methods eq or neq is implemented, then the implementation is full.

I made the example specific to eq and neq but it can be generalised to any interface, where implementation of one attributes can be evaluated on another attributes.

I can't find that doc now, so asking if anybody have it at hand.

0 Answers
Related