updated
authorChristian Urban <christian dot urban at kcl dot ac dot uk>
Thu, 01 Dec 2016 12:19:52 +0000
changeset 76 bc0e0aa4dee1
parent 75 71e463b33a9e
child 77 3cbe3d90b77f
updated
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
 //========================