blob: 3b39a7cabfaf5102f0d27b1bc96b89b40ebd0251 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
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 mics1 {
def main(args: Array[String]) = {
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);
}
}
}
|