mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-11-26 20:34:32 +03:00
Merge pull request #1955 from pikazlou/scala-pattern-matching
added docs for default case in pattern matching
This commit is contained in:
commit
97b21a7865
@ -460,6 +460,9 @@ def matchEverything(obj: Any): String = obj match {
|
||||
|
||||
// You can nest patterns:
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user