mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
added docs for default case in pattern matching
This commit is contained in:
parent
e56bc6cbca
commit
d47f06345b
@ -454,6 +454,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
|
||||||
|
Loading…
Reference in New Issue
Block a user