diff options
author | Martin Odersky <odersky@gmail.com> | 2004-05-07 12:44:43 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2004-05-07 12:44:43 +0000 |
commit | 3d80e28b90be83418beb3bc931140a273afdfc4c (patch) | |
tree | 91e16c7a6cdd24f751bf2baadc26b65458e06916 /doc | |
parent | 011b49957d4fc458a73b1a0434d549dc0ff7183c (diff) | |
download | scala-3d80e28b90be83418beb3bc931140a273afdfc4c.tar.gz scala-3d80e28b90be83418beb3bc931140a273afdfc4c.tar.bz2 scala-3d80e28b90be83418beb3bc931140a273afdfc4c.zip |
*** empty log message ***
Diffstat (limited to 'doc')
-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} |