Skip to content

Commit

Permalink
doc: Clarified 4.2 Pattern matching
Browse files Browse the repository at this point in the history
Combined redundant paragraphs about the match expression and removed a
redundant example.
  • Loading branch information
iliekturtles committed May 5, 2014
1 parent ecc18f3 commit 81bc32d
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/doc/tutorial.md
Expand Up @@ -468,19 +468,16 @@ Unlike in C, there is no "falling through" between arms: only one arm
executes, and it doesn't have to explicitly `break` out of the
construct when it is finished.
A `match` arm consists of a *pattern*, then an arrow `=>`, followed by
an *action* (expression). Literals are valid patterns and match only
their own value. A single arm may match multiple different patterns by
combining them with the pipe operator (`|`), so long as every pattern
binds the same set of variables. Ranges of numeric literal patterns
can be expressed with two dots, as in `M..N`. The underscore (`_`) is
a wildcard pattern that matches any single value. (`..`) is a different
wildcard that can match one or more fields in an `enum` variant.
The patterns in a match arm are followed by a fat arrow, `=>`, then an
expression to evaluate. Each case is separated by commas. It's often
convenient to use a block expression for each case, in which case the
commas are optional.
A `match` arm consists of a *pattern*, then a fat arrow `=>`, followed
by an *action* (expression). Each case is separated by commas. It is
often convenient to use a block expression for each case, in which case
the commas are optional as shown below. Literals are valid patterns and
match only their own value. A single arm may match multiple different
patterns by combining them with the pipe operator (`|`), so long as every
pattern binds the same set of variables. Ranges of numeric literal
patterns can be expressed with two dots, as in `M..N`. The underscore
(`_`) is a wildcard pattern that matches any single value. (`..`) is a
different wildcard that can match one or more fields in an `enum` variant.
~~~
# let my_number = 1;
Expand Down

0 comments on commit 81bc32d

Please sign in to comment.