# HG changeset patch # User Christian Urban # Date 1480594792 0 # Node ID bc0e0aa4dee1607c8e61acddff4037751a268582 # Parent 71e463b33a9e10861e0754de93efe80ebd833e1f updated diff -r 71e463b33a9e -r bc0e0aa4dee1 progs/lecture2.scala --- a/progs/lecture2.scala Sat Nov 26 19:12:33 2016 +0000 +++ b/progs/lecture2.scala Thu Dec 01 12:19:52 2016 +0000 @@ -180,9 +180,6 @@ - - - def my_flatten(lst: List[Option[Int]]): List[Int] = lst match { case Nil => Nil case None::xs => my_flatten(xs) @@ -200,6 +197,16 @@ get_me_a_string(0) +// you can also have cases combined +def season(month: String) = month match { + case "March" | "April" | "May" => "It's spring" + case "June" | "July" | "August" => "It's summer" + case "September" | "October" | "November" => "It's autumn" + case "December" | "January" | "February" => "It's winter" +} + +println(season("November")) + // User-defined Datatypes //========================