summaryrefslogtreecommitdiffhomepage
path: root/scala.html.markdown
diff options
context:
space:
mode:
Diffstat (limited to 'scala.html.markdown')
-rw-r--r--scala.html.markdown19
1 files changed, 19 insertions, 0 deletions
diff --git a/scala.html.markdown b/scala.html.markdown
index d6524a8f..d0187667 100644
--- a/scala.html.markdown
+++ b/scala.html.markdown
@@ -135,10 +135,29 @@ Person("George", "1234") == Person("Kate", "1236")
// Pattern matching
+val me = Person("George", "1234")
+
+me match { case Person(name, number) => "We matched someone : " + name + ", phone : " + number }
+
+me match { case Person(name, number) => "Match : " + name; case _ => "Hm..." }
+
+me match { case Person("George", number) => "Match"; case _ => "Hm..." }
+
+me match { case Person("Kate", number) => "Match"; case _ => "Hm..." }
+
+me match { case Person("Kate", _) => "Girl"; case Person("George", _) => "Boy" }
+
+val kate = Person("Kate", "1234")
+
+kate match { case Person("Kate", _) => "Girl"; case Person("George", _) => "Boy" }
+
+
// Regular expressions
+
+
// Strings