Abstract types

trait Buffer {
  type T
  val element: T
}
abstract class Buffer[+T] {
  val element: T
}
abstract class SeqBuffer[U, +T <: Seq[U] ] extends Buffer[T] {
  def length = element.length
}

def newIntSeqBuf(e1: Int, e2: Int): SeqBuffer[Int, Seq[Int {
    val element = List(e1, e2)
  }

val buf = newIntSeqBuf(7, 8)
println("length = " + buf.length)
println("content = " + buf.element)

Can in turn have abstract type members.

Abstract types → are a → Scala Unified types.

Abstract types — Structure map

Clickable & Draggable!

Abstract types — Related pages: