27-08-2011, 09:46 PM
Tiens j'ai trouvé une façon plus proche de la version Erlang.
def area(g: Any) = g match {
case ("rectangle", w: Double, h: Double) => w * h
case ("circle", r: Double) => r * r * 3.14
}
scala> area("circle", 23.13)
res27: Double = 1679.890266
scala> area("rectangle", 23.12, 30.3)
res28: Double = 700.5360000000001