Merge pull request #1955 from pikazlou/scala-pattern-matching

added docs for default case in pattern matching
This commit is contained in:
Geoff Liu 2015-12-18 16:27:53 -05:00
commit 97b21a7865

View File

@ -460,6 +460,9 @@ def matchEverything(obj: Any): String = obj match {
// You can nest patterns: // You can nest patterns:
case List(List((1, 2, "YAY"))) => "Got a list of list of tuple" case List(List((1, 2, "YAY"))) => "Got a list of list of tuple"
// Match any case (default) if all previous haven't matched
case _ => "Got unknown object"
} }
// In fact, you can pattern match any object with an "unapply" method. This // In fact, you can pattern match any object with an "unapply" method. This