diff options
Diffstat (limited to 'doc/reference')
-rw-r--r-- | doc/reference/ReferencePart.tex | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/doc/reference/ReferencePart.tex b/doc/reference/ReferencePart.tex index ce9fdd298a..811fbe90a8 100644 --- a/doc/reference/ReferencePart.tex +++ b/doc/reference/ReferencePart.tex @@ -3485,7 +3485,8 @@ value (or sequence of values). The same variable name may not be bound more than once in a pattern. Pattern matching is always done in a context which supplies an -expected type of the pattern. We distinguish the following kinds of patterns. +expected type of the pattern. We distinguish the following kinds of +patterns. A {\em variable pattern} $x$ is a simple identifier which starts with a lower case letter. It matches any value, and binds the variable @@ -3756,6 +3757,12 @@ def length [a] (xs: List[a]) = xs match { } \end{lstlisting} +In an application of \code{match} such as the one above, the expected +type of all patterns is the type of the qualifier of \code{match}. +In the example above, the expected type of the patterns \code{Nil} and +\code{x :: xs1} would be \code{List[a]}, the type of \code{xs}. + + \chapter{Top-Level Definitions} \label{sec:topdefs} |