mirror of
https://github.com/rust-lang/book.git
synced 2026-07-16 15:18:30 -04:00
Clarify that the conditional expression is the one under discussion
Rather than the return expression. Fixes #3168.
This commit is contained in:
committed by
Carol (Nichols || Goulding)
parent
bb7e429ad6
commit
3962c0224b
@@ -31,10 +31,10 @@ the variants of the enum as its patterns</span>
|
||||
|
||||
Let’s break down the `match` in the `value_in_cents` function. First we list
|
||||
the `match` keyword followed by an expression, which in this case is the value
|
||||
`coin`. This seems very similar to an expression used with `if`, but there’s a
|
||||
big difference: with `if`, the expression needs to return a Boolean value, but
|
||||
here it can return any type. The type of `coin` in this example is the `Coin`
|
||||
enum that we defined on the first line.
|
||||
`coin`. This seems very similar to a conditional expression used with `if`, but
|
||||
there’s a big difference: with `if`, the condition needs to evaluate to a
|
||||
Boolean value, but here it can be any type. The type of `coin` in this example
|
||||
is the `Coin` enum that we defined on the first line.
|
||||
|
||||
Next are the `match` arms. An arm has two parts: a pattern and some code. The
|
||||
first arm here has a pattern that is the value `Coin::Penny` and then the `=>`
|
||||
|
||||
Reference in New Issue
Block a user