--- a/progs/lecture2.scala Sat Jun 22 08:39:52 2019 +0100
+++ b/progs/lecture2.scala Wed Jul 24 14:22:06 2019 +0100
@@ -366,7 +366,7 @@
// you can also have cases combined
-def season(month: String) = month match {
+def season(month: String) : String = month match {
case "March" | "April" | "May" => "It's spring"
case "June" | "July" | "August" => "It's summer"
case "September" | "October" | "November" => "It's autumn"
@@ -380,6 +380,15 @@
println(season("foobar"))
+// Days of the months
+def days(month: String) : Int = month match {
+ case "March" | "April" | "May" => 31
+ case "June" | "July" | "August" => 30
+}
+
+
+
+
// Silly: fizz buzz
def fizz_buzz(n: Int) : String = (n % 3, n % 5) match {
case (0, 0) => "fizz buzz"