blob: 8d5cecf04382a790d778a34f76c79f893aa51b7b (
plain) (
tree)
|
|
abstract class IntMap[a] {
def lookup(key: Int): a = match {
case Empty() => error("key " + key + " not found")
case _ => error("ok")
}
}
case class Empty[a]() extends IntMap[a];
object Test {
def main(args: Array[String]): Unit = {
val key = 2000;
val map: IntMap[String] = new Empty[String];
System.out.print("lookup(" + key + ") = ");
try {
System.out.println(map.lookup(key));
} except {
case e => System.out.println(e.getMessage());
}
}
}
|