Vereinigung mittels Interfaces

I mathend000# repräsentiert die Vereinigung von A mathend000# und B mathend000#:

interface I { }
class A implements I { int foo; }
class B implements I { String bar; }


Notation dafür in Scala (http://scala-lang.org/)

abstract class I
case class A (foo : Int) extends I
case class B (bar : String) extends I
Verarbeitung durch Pattern matching
def g (x : I): Int = x match {
    case A(f) => f + 1
    case B(b) => b.length()  }



Johannes Waldmann 2014-03-31